Reputation: 137
I add a local service to my MainActivity, in the onResume, I did this
@Override
public void onResume() {
super.onResume()
boolean is_start = isMyServiceRunning(MyService.class)
if (is_start) {
bindMyService()
} else {
startMyService()
bindMyService()
}
}
In onPause I just simply do the "unBindMyService" operation.
Also, I add the Context.BIND_AUTO_CREATE flag to bind the service, the result is very strange.
So what happened between 4 and 5? The service is still alive or is dead?
Upvotes: 0
Views: 1328
Reputation: 885
you need to stop service to call onDestroy. Use this:
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
stopService(new Intent(this,MyService.class));
}
Upvotes: 1