I am not sure on the observation from my little experiment. I understand the life cycle of IntentService that it stops itself when it completes all the Intent to be handled.
My experiment was to identify the relation between the IntentService's life based on life of the Activity that started the IntentService.
MainActivity: creates ResultReceiver and passed it to IntentService.
MyResultReceiver: listens for onReceiveResult and writes log lines.
IntentService: writes log line on start, destroy and in onHandleIntent before returning result. Also has 15 seconds thread sleep for experimenting.
- Regular case, all logs lines are written including the onDestroy of IntentService.
- when I minimize the app log line from onPause of activity is logged. Then after sleep time all pending log lines form IntentService is logged including onDestroy.
- When I kill the app, I see log from Android Studio that app is been terminated but i do not see any logs from onDestroy of IntentService.
this 3rd case has left me short handed, did the Android Studio loose the connection to receive logs or did the IntentService got into different situation.
I am guessing it is due to Android Studio, but i want to be sure.
Regards,
Harsha