I’m working on a project that needs an activity to connect to a local service if that service is running and start it if it is not running.
What is the suitable flag for such approach.
I’m working on a project that needs an activity to connect to a local
Share
This is simply accomplished by, for instance, passing
0in the last parameter to#bindService(Intent, ServiceConnection, int).E.g.
The
#bindService(..)call will returntruebut the service will not actually start and your service connection will not trigger until someone actually starts the service, e.g. using#startService(Intent). At least this is how it works on ICS and Gingerbread.