I want to do this acts with my Service :
1)start App
3)start a Service by App
4)update my UI by Service
5)close App but the Service keep work
6)sart App again
7)connect to Service (not run new Service)
I want in my service public variable during living Service do not change.
If you return
START_STICKY
fromonStartCommand()
then yourService
will run unstil it is explicitly stopped. You can then decide how you want to stop yourService
, either by something callingstopService()
or by theService
callingstopSelf()
when it no longer wants to run.Please also note that Android can kill your
Service
pretty much whenever it wants to. If you have returnedSTART_STICKY
then Android will restart yourService
after it kills it, but there is nothing you can do to ensure that Android will not kill yourService
.