I have the following scenario with a PlayerActivity.
When I press the back button on the Player (while it's playing), the PlayerActivity calls the onPause(), then onStop() and finally onDestroy() as expected.
However, when I cause the PlayerActivity to go into the paused state (such as initiate a Voice search) and then allow it to go into the resumed state (by exiting the voice search), and then press the back button the Activity's onStop() and onDestroy() methods are not called - only onPause() is called.
So my question is this - is there a reason why onStop() isn't called even though the Activity is no longer visible?
These are the logs to help visualise this scenario:
Normal activity lifecycle for player:
01-10 18:44:58.799 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onCreate()
01-10 18:44:58.916 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onStart()
01-10 18:44:58.917 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onResume()
Back button pressed on PlayerActivity:
01-10 18:45:14.768 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onPause()
01-10 18:45:14.968 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onStop()
01-10 18:45:14.968 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onDestroy()
PlayerActivity destroyed.
Player initiated second time:
01-10 18:45:21.874 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onCreate()
01-10 18:45:21.899 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onStart()
01-10 18:45:21.899 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onResume()
Voice control is initiated on TV remote - causes Activity to PAUSE state
01-10 18:45:27.180 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onPause()
Voice control finished causing Activity to RESUMED state
01-10 18:45:29.414 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onResume()
Back button pressed on PlayerActivity
01-10 18:45:32.160 27817-27817/com.google.android.exoplayer2.demo D/PlayerActivity: onPause()
// This is it - Activity’s onStop() and onDestroy() not called