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?
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
The ciclelife of the media class do that automatically. Try @override on OnResume and OnPause methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With