Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've noticed many (if not all) android games don't support the "back" button functionality during their loading screens. Which leads to some frustrating moments when a user accidentally starts up the game and has to wait for the long loading stage to end in order to close it.

So my questions are:

1) Why is that ? Is there a good reason to avoid something like asynchronous loading (or some other solution to this problem) in android games ?

2) If there is no good reason not to support this functionality, what would be the best way to accomplish it ?

share|improve this question
    
Plants vs Zombies also doesn't let you press back during loading, and you're right, it's annoying. Also annoying if you can't hammer the back button to exit an app, we Android guys are used to being able to do this. –  John McDonald Nov 2 '12 at 19:49
    
Instead of individually listing games which don't let you press "back" during loading, can someone point out a game -- on any platform -- that does let a user choose to go "back" in the middle of a loading screen? –  Trevor Powell Nov 2 '12 at 21:12
    
@Trevor all PS3 games must do it on eject disc or quit in the XMB. It must work at all times, its a TRC. –  Maik Semder Nov 2 '12 at 22:09
    
@MaikSemder So it's just quitting the application that's desired in this situation? Seems sort of trivial to me. I mean, if the question is: "how do I exit the application when the back button is pressed?" then the answer is: "pay attention to whether or not the user presses the back button, and if he does, then exit the application". How much more is there to say? –  Trevor Powell Nov 2 '12 at 22:18
    
@Trevor a clean shutdown from every possible state in a game is not trivial, particularily if you have to unregister resources and subsystems. Often there is a time-limit involved, in which your app has to be done with all the cleaning. In a multi-threaded app this can mean a significant amount of work, especially in the loading phase. That's why there is even a TRC for it. It's not impossible, but it's far from easy too. It's just simpler to focus on fast loading and don't bother with a shutdown requests. It's a bit lazy, that's why personally I like systems with hard certification processes. –  Maik Semder Nov 2 '12 at 23:04
show 4 more comments

2 Answers

up vote 1 down vote accepted

One possible reason for a game to not support the back button when the game is loading is due to the nature of Android. When your application first starts you have one thread the UI thread. This thread is responsible for button input, rendering the GUI and handling the GUI logic. if you then try to load data on this thread in a non-asynchronous manner you will block the thread and freeze the applications UI. This means that all buttons would become unresponsive as that is handled on the blocked thread. Blocking the UI thread in this manner goes against good design principles for the Android platform.

  1. There is no good reason to avoid asynchronous loading, in fact to follow the Android guidelines you should use async-loading and threading to not block the UI thread.
  2. What you would want to do is handle your data loading on a separate thread. If you are making a game with OpenGL ES 2.0 you would more then likely have the UI Thread, the OpenGL thread and a GameLogic thread. You just need to make sure to manage what can be done on each thread. You can load basic game data in the GameLogic thread but you cannot do any OpenGL or Android UI initialization you will have to queue those events on the respective thread. Managing all of this can be quite complex to keep track of at times. And there may be times you need to block the UI thread for a short while to load something that can only be created on that thread. If you want to exit early you need to terminate whatever threads are running and then shutdown cleanly.

For more information on threading on Android: http://developer.android.com/guide/components/processes-and-threads.html

share|improve this answer
    
Thanks ! one more question though, does any of the android game engines (andengine,libgdx etc..) support this ? –  Oren Nov 9 '12 at 10:46
    
Not too sure on if AndEngine and libgdx support it. I have only built game engines on the Android platform I have not used any. –  leonmajere Nov 9 '12 at 21:42
add comment

This sounds like user error to me. The home button is always available to exit the game.

share|improve this answer
1  
the way I see it, good design provides the user with the functionality he/she expects (based on established usage patterns). would you say its unreasonable for a user to expect the back button to properly shut down a game (or app) when used in its initial stages ? most apps support this, why should games be different ? –  Oren Nov 2 '12 at 20:33
    
I'm inclined to agree with you, but I think the home button is designed to do what you're wanting. In any case, you're the designer, so you should do whatever you think makes sense. –  stephelton Nov 3 '12 at 18:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.