Gather ’round boys and girls. For story time today we’re going to talk about the importance of meeting user expectations for how android apps operate. If you’ve ever used an android phone, you’ve probably noticed that the two most important buttons are the Back and Home keys. When you press the Back button you expect to, well duh, go back. And when you press home (and click your heels together three times) you expect to be brought back to rural kansas with Todo by your side. No? Oh well then you probably were just trying to get back to your home screen.
TECHNICAL CONTENT WARNING!
Now what you may not be aware of is what these two buttons are actually doing. I won’t get too bogged down in the details, but essentially Android OS uses different stacks for your applications that hold the different things you are doing, known as activities. You could have a messaging stack, web browser stack, or a contacts stack for example. If you’re in the messaging stack, the first screen you see is put on the bottom of the stack. Once you select “text messages” from this screen, your list of text messages is called forward and placed on the top of the stack while the message service select activity is paused in the background. Likewise, when you click on a particular text, the text message is displayed as the top activity on the stack while the other two are paused beneath it.
When you hit the Back button, your phone destroys the activity on top of the stack which leaves the one beneath it. In our example, hitting the Back button would result in you returning to your text message list. Hitting it a second and third time would bring you back to the messaging service select screen and then the home screen. The interesting thing here is what happens when you push the Home button. Android returns you to the home screen, but keeps the current state of the activity stack in place. Therefore, you can go on opening other apps and creating many different stacks, but when you return to the messaging stack you will see the same thing that you saw before you pressed the Home key (providing your phone didn’t decide it needed to conserve memory and destroy the stack). There’s a lot more to it than that, but for the purposes of this conversation that’s all you need to know. If you want to learn more, the android dev site
You can come back now, it’s safe
Based on what we just talked about, there is an expectation among android users that when you press the Back button the phone goes back and when you press Home the phone returns to the home screen but remembers where you were when you left. In order to have more flexibility, most games are created using only a single activity. This lets them draw to the screen as fast as possible which, in turn, generates smoother graphics. The downside of this is that we can no longer allow the Android OS to handle moving around within our game because it sees it as only one activity and will immediately destroy it once the back button is pushed.
I thought it was important that our game mimic the android experience, however, and have intercepted the back key so that I can control what happens instead of the OS. The implementation was pretty straighforward; everything launches from the main menu
so that’s realy the only place you have to go back to. From any point in the game or secondary menus, if you press the Back key, you return to the main menu
as expected. If you press the back key on the main menu
, a message is displayed prompting you if you really want to exit. From here you can either check yes or no, but if you push the Back key on this screen the game will exit. I did this because, if anyone else is like me, they just keep mashing the back key until the application has exited and I wanted to make sure this still worked.
The Home key was a little less straightforward. Did we want
the user to return to the same place? The answer for this pretty much came from our earlier decision not to have a pause screen because the the user would be able to exploit it during faster rounds. If you were in the middle of a game and pressed the home key (or got a phone call), when you returned you’d be in the middle of game. Instead, we decided that you’ll just return to the main menu
. Now this DOES mean that if you were having a really awesome game and someone calls you that you’ll have to start over, but we felt this was the best solution. For you diehard highscore fiends, might I suggest Airplane Mode?
Words? I just want PICTURES!
Fine, fine! Here’s some pictures of a few changes we’ve made. Notice the new heart that floats away when you pet the kitty. She loves you! We’ve also made the notification bar larger so we can
insult praise you with more words.
I thought green means go?!
Here you can see the insult bar twisting the knife after you make a mistake on a really easy level. Seriously, how hard is it to pop the red balloon? Actually, I’ve noticed it’s really hard at first because our minds always want to avoid the red one. I guess you’ll just have to adjust. You can also see our REALLY big X that pops up when you lose a life. I’m currently in the process of animating the X to shrink down and fly into the lives bar. It’ll look cool once it’s completed and you will all worship me!
Until next time, minions.