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
Activity
onResume
is called before the oldActivity
onStop
method
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
-->setContentView
is called here - Activity
onResume
--> herebindService
is called and should create theService
- Fragment
onResume
- Service
onBind
method is called
My question is why is there a something else between my bindService
and onBind
calls?? I have a feeling this has something to do with threading issues.