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.

Newcomers AppGameKit Corner / Sending app to background with the Android back button

Author
Message
mattyjy2k
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location:
Posted: 5th Sep 2018 08:45
Hi, I believe the correct behaviour for a Android app is to send the app to the background when the device back button is pressed multiple times and I am trying to work out how to do this in Tier 1
I see most AppGameKit apps seem to use end and exit the app like this:
if GetRawKeyPressed(27) = 1
end
endif
However I have heard that If the app itself is terminating then it can throw up OS error flags on some devices.
If possible can anybody please help me in sending a app to the background in Tier 1 as I have not learnt Tier 2 yet.
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 5th Sep 2018 10:27



blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Sep 2018 10:52
I don't think there is a command to send the app to background. There is a GetResumed() function that will tell you if your app has regained focus.
mattyjy2k
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location:
Posted: 5th Sep 2018 11:31
Thanks Icerion but when the while loop is exited it will still terminate the app with the End command which is what I am trying to avoid.
mattyjy2k
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location:
Posted: 5th Sep 2018 12:12 Edited at: 5th Sep 2018 12:16
Thanks for the reply blink0km I was thinking the same that the command is not avalible in Tier 1 as I spent a long time looking trough the commands and help files before asking.
As you say the GetResumed() command is great for regaining focus if the app os sent to the background with the android menu button
but most Apps that are not built with AppGameKit do seem to send the App to the background with the back button as I believe Android itself wants to determine when to close the app which is what can cause OS error flags on some devices.
somebody called Naphier fixed this in Tier 2 with a simple modification to the AGKHelper.java file:


Then in your AppGameKit code you can call ShowMessage("-1") when the back button is pressed to send the app to the background.

But I was hoping there was a way in Teir 1.
mattyjy2k
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location:
Posted: 5th Sep 2018 12:29
Or maybe Naphier fix is the answer and I'm being too dumb to work out where to find the AGKHelper.java file to edit?
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 5th Sep 2018 17:06
@mattyjy2k :: Just remove the end. It still works.
mattyjy2k
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location:
Posted: 8th Sep 2018 12:15
I found the answer it was really simple MinimizeApp() it pauses the App and sends it to the background on Andriod without terminating.
On desktop it just minimizes the app as you would expect and on Iphone it does nothing as there is no back button anyway.

Login to post a reply

Server time is: 2024-04-26 13:02:07
Your offset time is: 2024-04-26 13:02:07