Open the application (when it is closed) via java code - java

I'm programming a video call app and everything seems to be working. There is only one problem. When one person calls another, the activity "Calling activity" (of the called person) opens only if the person who has been called has opened / opened the application (not when the app is closed). I would like to find a way that when one person calls another even if that other person has the app closed it still opens. How could I do? I leave you my callingactivity code
https://codeshare.io/ar0yxE

What you seem to need is a background process which listens for incoming calls on your receiving port or what have you - you can then launch the application if the recipient picks up or accepts thew call. The Android Docs have a page on background processes and another page on overriding the call interface for your own app
Good luck with the app

Related

Is there a way to process an Intent in Android without creating an Activity?

I'm creating an app that receives a link and sends it to an external server, so the links it's processed there. I followed these steps from Android Fundamentals, and I'm also able to send the link to the server.
The problem with this solution is that it creates an empty activity everytime i share a link with my app, and I don't need to display anything(maybe a Toast, but not an activity). I tried calling the method finish() after the link is sent, but I usually get the "Application not responding" message, so I don't think thats the best solution.

Application class gets recreated after opening some other applications

I'm new at developing Android. I'm experiencing the following problem:
I'm working on a Android application that extends the Application class. The values for the authentication session are stored in this class, because it is supposed to get created once and it is available in all activitys and services.
When I open my application and close it with the home button, and reopen it after I opened a lot of other apps, the base application class gets recreated (onCreate gets called). When this happens, I lose my authentication values. It seems like it that the onTerminate or onLowMemory are not getting called before the onCreate is getting called again. The current state of my application is not gone, because the previously active activity is still available.
When I close the app with the home button and only open a few other apps, the application resumes normally.
I also tried to implement a singleton class, but the singleton object is also null if the application class gets recreated.
How can I prevent the recreation of the application class, or work around this problem?
Thanks
Jacob
I found out that the application class can also be restarted as part of the application lifecycle. I stored my authentication values in preferences to solve this problem
From documentation of Application.onTerminate():
This method is for use in emulated process environments. It will never
be called on a production Android device, where processes are removed
by simply killing them; no user code (including this callback) is
executed when doing so.
Also there is no guarantee that onLowMemory will be called. Check this answer.
The current state of my application is not gone, because the
previously active activity is still available.
I think activity is just restored from Bundle.
How can I prevent the recreation of the application class, or work
around this problem?
You have to be ready that you application can be recreted in any moment. You can store some data in this class but before grab this data from some activity you should check if it is null. It will be null in first start and after application recreating. Just fill it with your data and return to activity.

Is it possible that the service still runs after the app got killed with task manager?

Hello im triying to run a service in background that it doesn't stop when app is destroyed by task manager. The idea of the service is verify every "x" min if there a new insert in a database that i got in a server.
The service is running great even if i close the app but when i use the task manager to destroy my app all the threads are closed too.
So i want to know if its possible to run a thread that ask in background forever unless user cancel it in the app itself, that ignore the destroy caused by task manager so in the future i can use notification bar to tell the user that a new insert happened in the database.
Tryed:
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
askServer(); // i made a timertask that ask every "x" minute
return START_STICKY;
}
As i read START_STICKY should run again the service if it get killed for some reason and i know that this can be done since some app get closed by taskmanager and still get notifications from it as whatsapp,bbms and others. Please tell me if im wrong in anything and thank you for reading!.
UPDATE: Im not trying to break any law or security rule from Android and im not trying to ignore the stoping services option from an app in settings. I want that the service that listen for new incoming "events " inserts in my case keep running after user used the interface that appear when you press home for a while :
UPDATE : sorry for talking to much about this app but is the one that i can use as an example. In whatsapp when i close the app by the interface that i showed above the process and services are killed but after a couple of second they relaunch, this is exactly what i want to do to keep user informed about database events. From setting you still can stop the service without problem or even i can put the option in the app itself to stop notifiying.
Is a bad implementation call in OnDestroy() method an instance of the service so it relaunch after destroy?
UPDATE : welp looks like my service is still running on background after i close the app. I will just have to work on my service design to not waste battery life and resources. Also i was using the log.i() to check if service was running, looks like when main process closes i can't use log or toast just notifications ( still not implemented) because the service is there running just won't show in log .
UPDATE : now is working using using startForeground(0, null). In future i will send a notification to show when a event on database happen building it and calling startForeground(1, notification).
For services, look at Settings -> Applications -> Services. and see if it is running.
However, poorly designed services may run more often or perform syncing operations. So yes it is possible.
I had a problem similar to this when developing my first android game; force-stop was the only way to kill it.
START_NOT_STICKY will kill the background service when you swipe the app away from the task manager. START_STICKY is, as the name implies, "sticky", Meaning it sticks to the android system even when the app is gone.
That's from my experience, anyway.

When a web service call was invoked in BlackBerry, application hangs

I am creating my very first blackberry application that tries to connect to a rest web service. I tried the example I found in the internet. Please refer to this link: http://mobile-development.org/index.php/blackberry/how-to-call-restful-web-services-in-blackberry
I tried to implement it in my simple BlackBerry application which is the one that is automatically created when you create a new BlackBerry project in BlackBerry Plug-in for Eclipse IDE. I just placed the code (literally copied and pasted it) in my button, that when clicked, will execute such code. But, when I click the button, the application hangs.
When I implement a code that simply outputs "Hello" in the output log, the application works perfectly fine. What is the reason behind it? Do I need to run the web service call in a separate thread? Please help. Thank you in advance.
--------------------PLEASE READ BELOW----------------------
I noticed that my application hangs because it waits for a response from the web service call of at least 2 min. I read through this: http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is_-_Different_ways_to_make_an_HTTP_or_socket_connection.html?nodeid=826935&vernum=0 -- and added "deviceside=true" at the end of the url (http://yourwebserviceurl.com;deviceside=true"). It works fine now. Maybe the proper implementation for this is to do the task in background or in a separate thread and set the timeout which I do not have a knowledge on it yet. I'm still confused on whether to set the deviceside to true/false. Should I set the deviceside to true when I'm running my app in a simulator then just change it to false if I want it to run in an actual device? That is for me to discover for now or you can help me out on this one as well. ;-)
The Code they have given is in for HTTP connection , It is totaly fine, But what we need to do call this code in a thread , because ui works also in thread by which by which it got stuck.
So you need to use thread concept here.
Look at Samples provided into
Eclipse helios\plugins\<sdk version>\components\samples\com\rim\samples\device\httpdemo
Whenever you wants to update UI In a background thread , use
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
<Update UI>
}
});
I hope it may help you .

How to "control" a call in android?

im developing an app where one should be able to call and "reject" a call from the desktop using a small socket program to communicate with the phone over USB.
I got most of it in place, I can call a number from my desktop application, however, when a call is being made it is not under control of the application.
I run a service which starts a server socket thread, and then I bind the local listen port to my computer with adb forward tcp. When I send a CALL:123123 it will start a new call intent that calls the number "123123".
How would I go about making a call and then at some point ending it again?
I'm almost sure this is not possible to do programatically. Android doesn't let programs make manipulate phone calls without some user interaction due to security concerns.

Categories