One of my actions is VideoViewto play some content. I implemented the suspension / resumption of the video in onPause()and onResume(), accordingly, but to my surprise - onResumeit is called before the action is really visible to the user.
To be precise, the scenario is as follows:
- screen activity, video playback
- the user locks the phone with the power button.
- activity receives
onPause(), video stops - user presses power button
- activity gets
onResume()(and thus resumes the video) before the user unlocks the screen
I have confirmed this behavior of Android 2.2, 2.3 and 4.0. I assume that this is intentionally done so as to allow the activity to prepare for redrawing immediately after the screen locks.
How can I determine when the action really appears to the user? I tried to wait for it to onWindowFocusChanged(true)be called, and it seems to work, but that does not make me completely safe.
source
share