I’m working on a media streaming app, and noticing some odd behavior. Media stops playing when my device locks, but then starts playing again before I even unlock the device.
Any suggestions what might cause this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is due to the way the Android lifecycle works when you hit the unlock button but are still on the lock screen.
onResume() doesn’t necessarily mean your app is visible — only that it’s active. In the case of a locked phone, onResume() is sent as soon as the screen turns on, even though the phone’s display is on the lock screen.
This is detailed in this blog post:
http://android-developers.blogspot.com/2011/11/making-android-games-that-play-nice.html