Hi and thanks for your help.
I have the following situation.
My Activity is bound to a Service that performs heavy data retrival from internet via an AsyncTask.
Since the Service is heavy I need to make make sure it is stopped when the user navigates away for the Activity, therefore I make sure to stop the service in onDestroy()
.
When configuration changes onDestroy()
is called - and so are onPause()
and onStop()
- and subsequently the Service is stopped by onDestroy()
.
The point is that I do not want the Service tho stop on configuration change.
Please any suggestion very much appreciated!
And thanks for your help!
You can call isChangingConfigurations()
in onDestroy()
on API Level 11 and above. You can refer to this post, How to distinguish if activity is changing configurations.
Maybe you should take another approach. I think you should use a IntentService
(which runs in background, no more need for AsyncTask
), use that service to retrieve & store data, and then notify the Activities
that the data is updated, using a Broadcast
maybe.