Android: i want to create service by extending a Service class which i start when application get started and all activities can share its state and when i want stop it from other activity and when i want start it again from any activity ?
A:
You can write your own MyApplication
class extending Application
class, put it in AndroidManifest.xml
as
<application ... android:name=".MyApplication"> ... </application>
and start your service and bind to it in MyApplication.onCreate()
method.
You can access the binder from any Activity
class:
Application app = getApplication();
MyApplication myApp = (MyApplication) app;
myApp.getServiceBinder() // need to implement this method first
radek-k
2010-08-27 08:55:27