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 / How to make an app quit?

Author
Message
Santman
7
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 7th Sep 2012 00:48
Hi all. Here\'s a REALLY obvious question but I can;t find the answer. How do you force a quit from your program? Is there not an exit or end command? To date the only way I found was to set a label as the last line of code, then call that label when I want to quit. Is this it???
Digital Awakening
AGK Developer
16
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Sep 2012 10:26
The command you are looking for is END

Santman
7
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 7th Sep 2012 12:32
See, said it was simple. Lol. However, I tried that both with and without brackets, and I get a complete error. And opening the commands list, it's not there. Though I noted that exit to quit out of a loop isn't there either and that is in the principles section?

This may seem obvious, but does end have any specific parameters?
Digital Awakening
AGK Developer
16
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 9th Sep 2012 12:41
I use end in my code (just checked), no brackets or anything. Do you have the latest version of AppGameKit installed? Works great on both Windows and Android. If you are using the Android player make sure to download the latest beta version and not the long outdated market version.

Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 17th Sep 2012 18:19
First, I've been told and seen posted elsewhere that you should not have a button or menu option that says 'Exit' (or whatever) to manually close an app on an Android (like on iOS).

Having said that, using the End command in Tier 1 worked fine for me on Android devices. The command does not appear command lists, it does appear in the Language page (from the main docs page).

Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
9
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 19th Sep 2012 18:35
I think I read somewhere that pressing the "button" on Android devices can be trapped by checking for keycode 27 (that's the escape key), and that would be an acceptable way to close the program with the END command.

Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Sep 2012 20:25 Edited at: 19th Sep 2012 20:34
Rich, I think the issue is that Android apps (like iOS apps) are not supposed to have and Exit option. Not that it cannot be done.

In some apps, it might be okay to just close the app if the 'home' button is pressed (I'm going to write a quick app to see if that does produce the expected results). But others, like games or editing things, might be a problem if they just closed.

The issue appears to be the way Android apps work. They run lots of processes to do different things. And it is important that a closing app closes all the processes properly.

Now, the End call in Tier 1 might just do the right stuff, but I cannot find the code that executes in the agk files.

In the interpreter code reference to a function AppForceExit() which closes an app based on platform (does nothing in iOS) which I based my agk::closeThisApp() function for my code and templates. For the Android, it calls something called agk::MasterReset() and the exit(0). I know that exit(0) causes the app to close, but I don't know if it does it 'properly'. I don't know what MasterReset() does, since I cannot find it. Hopefully, it does clean up functions.


Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
9
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 19th Sep 2012 21:22
@AL - All I really know about it is that if I want my AppGameKit apps on my Android devices to "end" I have to go into settings and force quit them. Otherwise they hang around hogging memory, not running, but still there. While an AppGameKit app is running, I can hit the Home button, and I do get taken home, but the app is still in there, with no apparent way to close it and clear memory.

Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Sep 2012 22:00
Rich, I agree with you. All devices should allow you to manually close an app from within the app. This is a flaw in my opinion of the device standards (iOS and Android), not of AGK.

I initially had an exit option in my Android version (and I think I'm going to put it back) and took it out when I read about some 'standards' (but none officially posted anywhere).

However, when you use the End function on an iOS app, it takes forever to close. And I mean several to many minutes, depending on the app. I've seen it take 20 minutes before the app actually disappeared. It leaves a black screen during that time as well. I'm going to retry in my Tier 2, just to be sure. My recent code discoveries (see my posted templates in the 'AGK Product Chat' list) might mean the app closes sooner.

But Apple may reject apps with an Exit button. That is what I've heard, anyway.

Cheers,
Ancient Lady
AGK Community Tester
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Sep 2012 22:39
I just added 'Exit' to my iOS app, in Tier 2, and it closed immediately! And Xcode recognized that the app had closed when it was run on my iPod Touch from Xcode. Cool!

I'm going to leave the 'Exit' button in. If Apple complains, I'll remove it.

And I've added back the button on my Android. Same if they complain.

Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
9
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 19th Sep 2012 22:59
Good info, thanks!

JimHawkins
9
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 22nd Sep 2012 13:54
From my reading, "Metro" (or whatever it's called now) apps likewise do not close as such, but just sleep. So forcing an exit will be a similar issue on that.

-- 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: 22nd Sep 2012 18:04
I'm not worried about Metro for now. Based on Lee's blog for the Ultimate Coder Challenge, it will be long while before we are using AppGameKit for that platform. And it will be long while before I get a Metro/Windows 8 machine.

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2019-06-27 01:50:16
Your offset time is: 2019-06-27 01:50:16