Every device behaves differently.
I have already fixed the problem manually with this:
// Events
protected void onPause() {
super.onPause();
Log.v(“SDL”, “onPause”);
// If the screen is off then the device has been locked
PowerManager powerManager = (PowerManager)
getSystemService(POWER_SERVICE);
boolean isScreenOn = powerManager.isScreenOn();
//Screen locked
if (!isScreenOn) {
if (screenLock == 0){
screenLock = 1;
Log.v(“SDL”, "screen locked: " + screenLock);
// The screen has been locked
PauseMusic();
}
}
}
protected void onResume() {
super.onResume();
Log.v(“SDL”, “onResume”);
KeyguardManager km = (KeyguardManager)
getSystemService(Context.KEYGUARD_SERVICE);
boolean screenlocked = km.inKeyguardRestrictedInputMode();
//Log.v(“SDL”, "locked " + screenlocked);
if (screenlocked == false){
if (screenLock != 0){
screenLock = 0;
Log.v(“SDL”, "screen unlocked: " + screenLock);
// The screen has been unlocked
ResumeMusic();
}
}
}
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
//Log.v(“SDL”, “onWindowFocusChanged”);
if(hasFocus){
if (screenLock != 0){
screenLock = 0;
Log.v(“SDL”, "screen unlocked: " + screenLock);
// The screen has been unlocked
ResumeMusic();
}
}
}> ----- Original Message -----
Subject: Re: [SDL] About: Fixes Bug 1896 - Android app is running while
the screen is locked
From: Gabriel Jacobo
To: SDL Development List
Date: 08/07/2013 18:08
There’s definitively something different in our devices. On mine I get
the “Lock screen displayed!” message, but my app doesn’t get the
onResume message until after I enter the unlock code.
So, two questions:
- Do you have any customizations on your app manifest or configuration
that can make this happen?
- Thinking out loud here, but if this is an Android problem, how to
work around it? Basically how do we detect the lock screen is active.
Can anyone else pitch in with a quick test?
Gabriel.
2013/7/8 Giorgos Sarris <@Giorgos_Sarris>
Gabriel,
I attach the log.
In the log (onPause and onResume)
1) I press the 'lock key' I see blank screen and the music stops.
2) I press it again and I see the lock screen but the music started.
3) I unlock the screen and see the app normally.
I have a galaxy tab 2 with 4.0.4 OS.
Thanks,
Giorgos
-------- Original Message --------
Subject: Re: [SDL] About: Fixes Bug 1896 - Android app is running
while the screen is locked
From: Gabriel Jacobo
To: SDL Development List
Date: 08/07/2013 14:53
2013/7/8 Giorgos Sarris <@Giorgos_Sarris>
About: Fixes Bug 1896 - Android app is running while the screen is
locked
When the android device has a security lock screen enabled then
when you lock the screen it pauses
but when you unlock the screen with the hard button and you see
the android unlock screen (slide to unlock)
it un-pauses and even play the game music.
Is this supposed to happen?
Thanks
Giorgos
_______________________________________________
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
On my phone, a Nexus 4, this is not what I'm seeing. I lock the
screen with the power button, the app suspends and music stops. If I
wake up the device with the power button again, I see the unlock
screen, but the app remains paused. When I enter the unlock code, it
comes back to life.
Can you provide more information on your device, Android version,
and more importantly, can you check the adb log and see what events
the app is getting when you turn it on, pre unlock and post unlock?
--
Gabriel.
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
–
Gabriel.
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org