There is error in your patch. You are trying to check if surface is valid in onPause() but it will be always valid because surfaceDestroyed() called after onPause() in all cases.
NY00123 wrote:
Hey,
Interestingly, I have just spotted that last week. As a result I have
opened a bug with a suggested patch:
Android app is running while the screen is locked · Issue #907 · libsdl-org/SDL · GitHubWithout this, an SDL app can finish your battery life when you don’t
expect it! (Let’s hope it does finish it when you expect it otherwise…)Hi! Currently SDL thread suspends in SDLSurface.surfaceDestroyed() and
resumes in surfaceChanged(). It works great when you switch to another
app and come back, but such method doesn’t cover all cases! For example,
if you press Power button to lock your screen surfaceDestroyed() won’t
be called and your game won’t be paused, but it should, doesn’t it?
So why you chose this way? Why not to use onPause() and onResume()? Or
may be stop game when activity loses its focus? What do you think?
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Code:> On 06/10/2013 02:55 PM, mastermind wrote: