android - Variables of Application class are null when a new Service instance is launched -


i have mainapplication class extends application.
have alarmbroadcastreceiver class extends broadcastreceiver.
onreceive(context, intent) method of alarmbroadcastreceiver gets data intent , starts service. run service in separate thread , declaration in androidmanifest.xml:

<service android:name="***mypackagename***.alarmservice"                  android:process=":remote"> </service> 

the problem following: if close application clicking "home" button @ android 4.0, opening "recent apps" , pulling application left when service running, , launch application again (the service still running), new service, started when alarmbroadcastreceiver receives new intent, can't data of mainapplication class (even static variables of mainapplication null). why?
can't perform debug, because debugger deattached when close application...

why?

because added android:process=":remote", runs service in separate process, own separate copy of application object.

simply remove android:process=":remote", using more 1 process anti-pattern on android anyway.


Comments