From 32508f6db1d3f3c070e80ea42e0a1244a4c88cab Mon Sep 17 00:00:00 2001 From: victorfisac Date: Tue, 5 Jan 2016 12:21:40 +0100 Subject: Fixed Android lock screen bug - Fixed Android locking screen bug. OnDestroy() was called when locking screen. - Power button input must be handled by OS. - AndroidManifest.xml is affected by configChanges="screenSize". - Updated library header for android template. --- src/core.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core.c b/src/core.c index 96ce7176..40691403 100644 --- a/src/core.c +++ b/src/core.c @@ -1686,11 +1686,19 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) int32_t keycode = AKeyEvent_getKeyCode(event); //int32_t AKeyEvent_getMetaState(event); + // Save current button and its state currentButtonState[keycode] = AKeyEvent_getAction (event); // Down = 0, Up = 1 - //if (keycode == AKEYCODE_HOME) { } - if (keycode == AKEYCODE_POWER) { return 1; } - if ((keycode == AKEYCODE_BACK) || (keycode == AKEYCODE_MENU)) + if (keycode == AKEYCODE_POWER) + { + // Let the OS handle input to avoid app stuck. Behaviour: CMD_PAUSE -> CMD_SAVE_STATE -> CMD_STOP -> CMD_CONFIG_CHANGED -> CMD_LOST_FOCUS + // Resuming Behaviour: CMD_START -> CMD_RESUME -> CMD_CONFIG_CHANGED -> CMD_CONFIG_CHANGED -> CMD_GAINED_FOCUS + // It seems like locking mobile, screen size (CMD_CONFIG_CHANGED) is affected. + // NOTE: AndroidManifest.xml must have + // Before that change, activity was calling CMD_TERM_WINDOW and CMD_DESTROY when locking mobile, so that was not a normal behaviour + return 0; + } + else if ((keycode == AKEYCODE_BACK) || (keycode == AKEYCODE_MENU)) { // Eat BACK_BUTTON and AKEYCODE_MENU, just do nothing... and don't let to be handled by OS! return 1; -- cgit v1.2.3