Question

I got a situation where i have two APPS for simplicity keep it as APP1 and APP2, i am passing an object remoteCallback as CALLBACK from APP1 to APP2 for future use.

where based on result APP2 will instantiate a method updateStatus(String msg) using a object remoteCallback, Everything is working fine but, when i close the APP1 and clears the memory, APP2 is unable to call the method i know what causes this problem i want to know is there any way to make the object(remoteCallback) live even the APP1 closed.

Thanks in advance.

Was it helpful?

Solution 2

There is no way we cant stop an app from destroy so instead of passing an callback to get details use BROADCAST RECEIVER. This is the solution i adapted to this situation.

OTHER TIPS

I'd use an unbound Service here. Unbound services make that even if one of your apps close, if the conditions permit it, it will still be running in the background. If you used a bound Service, it would stop with your app if your app stopped.

This differs from an AsyncTask or a Thread, because even if they run in the background, there's a big change of being killed if Android needs more memory or is in lack of resources.

This introduce, however, a new responsibility for you: You'll have to make sure you use startService() or stopService() accordingly within your app and don't leave your Service running indefinitely.

This seems to be a good example about how it works, but you might find lots of documentation about unbound Services

"I want to know is there any way to make the object(remoteCallback) live even the APP1 closed."

PendingIntent ?...

Its the same mechanism used on notifications.

You can start the background service and the store the object which you want to live object after the app is closing

you can declare the public static data member and you use the whole application

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top