Skip to content Skip to sidebar Skip to footer

Android- Resuming Service In Activity And Destroying Them On Destroy

I currently have an Activty that when created starts and binds with a service. This service has a mediaplayer. What I would like to do is if the activity is resumed then the servic

Solution 1:

I'd say you got lucky that it stopped -- only onPause() is guaranteed to be called when your Activity is backgrounded. The only time onDestroy() is called is when the system decides to reclaim the memory your app is using

The only guaranteed lifecycle calls are:

  • onCreate() only when the app is starting from scratch;
  • onResume() every run, whether paused or first created;
  • onPause() every time the system is moving your app to the background, period.

Post a Comment for "Android- Resuming Service In Activity And Destroying Them On Destroy"