I'm facing a strange problem with my app. I have a LocationService that runs in the background. The way I manage its lifecycle is:
- In
onResume, every activity usesbindService(intent,serviceConnection, BIND_AUTO_CREATE)like that the service is automatically created when needed. - In
onStop, every activity usesunbindService(serviceConnection) - This works because when switching activities, the new
ActivityonResumeis called before the oldActivityonStopmethod
The problem I have is, lets say I start from the home screen and I launch the app with an Activity that has a fragment in it. The order of the function call is as follows
- Activity
onCreate-->setContentViewis called here - Activity
onResume--> herebindServiceis called and should create theService - Fragment
onResume - Service
onBindmethod is called
My question is why is there a something else between my bindServiceand onBind calls?? I have a feeling this has something to do with threading issues.