How to close Android application ?

Monkey Targets Forums/Android/How to close Android application ?

teremochek(Posted 2012) [#1]
How can I close an application in code?


Xaron(Posted 2012) [#2]
Error ""



therevills(Posted 2012) [#3]
I normally wrap:
Error ""


in a function called ExitApp:
Function ExitApp:Void()
    Error ""
End


Nice and easy to remember ;)


teremochek(Posted 2012) [#4]
thanks!


benmc(Posted 2012) [#5]
This used to work, but now it appears to be restarting the app instead.

Does anyone know a good way to completely exit and Android app?

I know that we're not "supposed" to, but every time I release an app that doesn't completely exit, I get negative reviews and emails telling me that I suck because my app doesn't completely exit, so it would be nice if the back button would exit the app somehow.

Not sure what to do.

EDIT:

I got MonkeyGame.activity.finish() to work, but it still leaves the process running in the background.

I also got System.exit(0); working, and it does kill the process, but apparently this is taboo for some reason.


dave.h(Posted 2012) [#6]
im using the latest version of monkey and just tested this on my phone and it still works fine on that.


Xaron(Posted 2012) [#7]
Same here. BTW: You never should really exit an app on a mobile device. Usually the OS takes care of that. That's why there are OnSuspend and OnResume methods.

On iOS it's actually a rejection reason if you exit your app. I've had this once...


therevills(Posted 2012) [#8]
You never should really exit an app on a mobile device.


I hate that, I know its meant to be "standard", but I really think its stupid. Mobile devices have limited battery and memory, so why keep an application running in the background when the user has finished with it!?!

On iOS it's actually a rejection reason if you exit your app. I've had this once...


Strange... I havent, and Angry birds quit the application when leaving via the main menu. Is it new?


Xaron(Posted 2012) [#9]
Strange... I havent, and Angry birds quit the application when leaving via the main menu. Is it new?


Don't know. But I have an explicit "Exit" button in my game Tic Tac Toe Wargames which I had to make "unfunctional" for the iOS version. I even attached some kind of special effect for that exit.


benmc(Posted 2012) [#10]
The reason I'm adding a full-on exit method is because users ask for it all the time. Just Android tho, nobody complains about this on iPhone, just seems to be Android :)

I might add an actual "exit" button to my Android App too, otherwise I get emails from people saying they don't know how to exit the app.


DGuy(Posted 2012) [#11]
I tweaked mojo.android.java a tiny bit so on pressing of the "Back" button, instead of a mock "KEYCODE_ESCAPE" keypress being generated, the "onBackPressed" handler gets called.

The handler itself is just:
@Override
public void onBackPressed()
    {
    super.onBackPressed();
    }
Which has the effect of popping the Monkey activity off the activity stack.

Didn't like that [monkeycode]Error ""[/monkeycode] purposely causes an exception as a means to exit the app.