Reputation: 834
I have a MainApplication
class which extends an Application
.
Also I have an AlarmBroadcastReceiver
class which extends BroadcastReceiver
.
onReceive(context, intent)
method of AlarmBroadcastReceiver
gets data from intent
and starts a service. I run service in a separate thread and this is its declaration in AndroidManifest.xml
:
<service android:name="***myPackageName***.AlarmService"
android:process=":remote">
</service>
The problem is the following: if I close the application by clicking "Home" button at Android 4.0, opening "Recent apps" and pulling the application to the left when a service is running, and then launch the application again (the service is still running), a new service, which is started when the AlarmBroadcastReceiver
receives a new intent, can't get data of MainApplication
class (even the static variables of the MainApplication
are null). Why?
I can't perform debug, because the debugger is deattached when I close the application...
Upvotes: 0
Views: 216
Reputation: 1006674
Why?
Because you added android:process=":remote"
, which runs your service in a separate process, with its own separate copy of your Application
object.
Simply remove android:process=":remote"
, as using more than one process is an anti-pattern on Android anyway.
Upvotes: 1