Can't exit game

Monkey Targets Forums/Android/Can't exit game

jowli(Posted 2012) [#1]
Hi Monkeys,

So after weeks waiting for an Android Market comment for my dumb "Super Maths Adventure" game, I get a one star review with this:

"No way to exit the game without restarting my tablet."

The device listed is a Motorola Droid (sholes).

Any ideas? I haven't tested on a tablet, except for an emulator. I don't have an explicit exit button in the game - I assumed it was the 'Android way'?

If you feel inclined to take a look. You can download it from here: https://market.android.com/details?id=com.jowli.game.mathadventure

Thanks


Volker(Posted 2012) [#2]
 
If KeyHit(KEY_ESC)
 Error("")
endif

This will close the App if the back button is hit.

I can simply press the home button to leave the app.


marksibly(Posted 2012) [#3]
Hi,

> I don't have an explicit exit button in the game - I assumed it was the 'Android way'?

It *is* the Android way! Same deal with iOS too - 'home' is the exit button..

Unless your app is somehow leaving something running or has disabled the home button or something, the review is crap.

[edit] Just had a play with it on my iconia a200 and it works fine (nice job!). Is there someone you can complain to at marketplace to get the review removed?


Dima(Posted 2012) [#4]
I've had similar problems on my Droid X, but nothing that persisted which makes me think my own code is responsible. At some times the back button would just not exit the app, at others the app would exit and restart itself right away, and most of the time things just work as expected. Not really sure what the problem may be related to, but on rare occasions something like that happens to me.

edit: im using the Error() method


therevills(Posted 2012) [#5]
Yep, once the last activity is done, pressing the back button should quit the application.

Since Monkey (currently) only has one activity, the back button should quit. Although I create different screens in my Monkey games, so I only quit when the user is on the Title Page for example.

I wrap Error("") to a more meaningful named function:

Function ExitApp:Void()
   Error ""
End


So I can do the following:
If KeyHit(KEY_ESC) ' esc = back button in Android
   ExitApp()
End



marksibly(Posted 2012) [#6]
Hi,

> Since Monkey (currently) only has one activity, the back button should quit.

Thought we'd been over this already, but I strongly disagree.

According to the Android SDK docs:


You can shut down an activity by calling its finish() method. You can also shut down a separate activity that you previously started by calling finishActivity().

Note: In most cases, you should not explicitly finish an activity using these methods. As discussed in the following section about the activity lifecycle, the Android system manages the life of an activity for you, so you do not need to finish your own activities. Calling these methods could adversely affect the expected user experience and should only be used when you absolutely do not want the user to return to this instance of the activity.



And iOS:


Q: How do I programmatically quit my iPhone OS application?

There is no API provided for gracefully terminating an iPhone application. Under the iPhone OS, the user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take - turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.



In other words, on Android/iOS at least, 'home' is the quit button - your app should not explicitly 'exit' itself.

[edit]
Deja vu! http://www.monkeycoder.co.nz/Community/posts.php?topic=193
[/edit]


therevills(Posted 2012) [#7]
Most apps Ive used on Android, when pressing 'Home' acts like minimising a desktop, whereas 'Back' pops the activity.

According to the Android SDK docs: and iOS:


What do they know, eh? ;)


jowli(Posted 2012) [#8]
I ended up doing what I usually do when not sure about something: I ask "What does Angry Birds do?"
Angry Birds let's you quit the game from the title screen via the back button, it pops up an "Are you Sure?" dialog, and then quits the app.

Therefore I've modified the game so that the back button quits from the title page.

Shame about the negative comment though, nothing I can do about I suppose except having to ask people nicely to write positive comments :-)


therevills(Posted 2012) [#9]
Shame about the negative comment though, nothing I can do about


Well you have done something about it! You've improved your game. If you stated in the release notes that you have "fixed" that issue, people can see that you responded to the feedback, which is what feedback should be about.

And you never know, the use who posted the comment, might also see that you have listened to them and change their comment ;)


Aman(Posted 2012) [#10]
i don't recommend anyone to add an exit button since it can cause the app to be rejected. Barns&noble considered it a bug and advice me to fix it before submitting the game again. Apple approved my first version but rejected the second one although the button existed on both versions!


therevills(Posted 2012) [#11]
i don't recommend anyone to add an exit button ...


For Apple, yes I agree... For Android I don't show an exit button, but when the user presses the back button on the title screen I then "exit" the app (sometimes with a confirmation).


Samah(Posted 2012) [#12]
As quoted:
Note: In most cases, you should not explicitly finish an activity using these methods. As discussed in the following section about the activity lifecycle, the Android system manages the life of an activity for you, so you do not need to finish your own activities.

This is assuming you haven't intercepted the back button and stopped Android from handling the activity stack for you. Monkey does this and cannot be disabled. We are therefore forced to provide that functionality by catching KEY_ESCAPE.

I think it's a fair trade-off really. It's great to be able to catch the back button for in-game menus, etc. but Monkey can't afford to let Android automatically kill the application if you haven't specifically coded for it. I see "manually ending the game" as being "disabling the code that catches the back key".


TeaBoy(Posted 2012) [#13]
Jowli,

Nice job on the maths game! works as expected!