Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Android / Android HOME Key issue?

Author
Message
The Daddy
10
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 15th Dec 2012 19:28
Hi All

Has anyone had the issue of (on Android) when you app\game is playing and the HOME key is pressed the game expectedly goes into background mode. However, when I select my app\game to bring it back into focus I simply get a blank screen???

Thankfully Mr Hawkins is ever so kindly looking at my project (Coded using Free Pascal (Lazarus) but so far he does not see any obvious issues with my code....Very frustrated and confused!

Any Help much appreciated!

Constantly seeking!
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 16th Dec 2012 13:52
I've been trawling around the nets on Android key stuff.

Here's my take on it:

* The Back button (also known as the Up button) should peel one layer back on the app's stack of sub-launches. It should only force an exit if there's no other thing. Consequently, I now think that a sensible guideline would be that if one's game has a main menu, pressing Back should suspend the current activity, and return to the menu with the possibility of resuming, quitting, or doing something else.

Simply forcing a quit seems a little brutal. Maybe a requestor should be shown asking if you really want to quit. This is normal behaviour in most other contexts!

* The Home key cannot be overridden. It will Pause the running app, and go where ever Home is deigned to be on the device. Eventually, it will will halt the app if memory is low or it hasn't been accessed for a long time.

* Many new phones do not have physical keys. I have yet to see an AppGameKit game that implements the interface bar with Back, Home etc on. Has anybody tackled this issue?

Is Tier 1 properly handling the Home button? If so, how is the App coming out of hibernation after the Home button was pressed, and then the app icon pressed?

Likewise, does anybody have a short example of Tier 2 code showing how the app is notified that Home has been pressed, and later, that it has been re-started?

Very grateful for your thoughts and info!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th Dec 2012 17:32
There isn't anywhere where the app is notified that the home button has been pressed. Theoretically you can catch it by checking GetRawKeyPressed(27), but I haven't tried that.

There is a GetResumed() command that notifies you that the app has just been brought back to the foreground from the background. It works fairly well in Android and they fixed in in v108 for iOS.

I use this as the first command in my main processing loop:


The same code (without the agk: works in Tier 1.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 16th Dec 2012 21:44
Apparently the Home key can't be handled. I think key code 27 is actually the back button.

What happens with your app when Back is pressed? Does it exit, or sleep?

Ta.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Dec 2012 11:27
I've found that it's not just Pascal that doesn't resume correctly:

http://forum.thegamecreators.com/?m=forum_view&t=202138&b=41

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Funnell7
7
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 17th Dec 2012 12:27 Edited at: 17th Dec 2012 12:30
Nothing happens when you press the back key unless you specifically code for it. For example, I check for GetRawKeyPressed(27) and then call my exit function (basically pauses the game with an 'Are you sure you want to quit' message).

There is no way currently to check for the Home Key pressed. Having said that, I wanted my app to close when pressing the home key (as opposed to going to background) and there is a way to do this by editing the core.cpp file (I use Tier 1)... The app then restarts from the beginning...
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Dec 2012 12:48
It's the Home key that's the main problem. A lot of AppGameKit apps, including Paul's 3D demo do NOT resume correctly when the app icon is re-clicked, and can totally hang the device.

What did you change in core.cpp?

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 19th Dec 2012 07:49
Looks likely that there is problem with Pascal generation that stops the Suspend/Resume signal getting to the app. This is being examined!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 25th Dec 2012 12:51
This problem has now been fixed. See the AppGameKit for Pascal thread in the main section.

Hurray!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL

Login to post a reply

Server time is: 2019-08-24 21:10:02
Your offset time is: 2019-08-24 21:10:02