Handle the onPause and onResume as well and put your game in some kind of sleep-mode (onPause), where it does absolutely nothing but just sit/ sleep there. When your activity that shows the game is brought to the foreground instead (onResume), bring it out of sleep mode and let the user continue the game.
Another, but highly 'controversial' option is to call System.exit() (or android.os.Process.killProcess(android.os.Process.myPid())). Since you have a one-activity game that is entirely stand-alone (i assume), this could be considered ok. On Dec 2, 7:47 pm, billconan <[email protected]> wrote: > Hello guys, > > I'm working on a game, mainly based on NDK. I now have a problem of > how to quit the application. Right now, i just implement my own > function to handle the "back" button. inside that function, I simply > call the activity.finish() api to finish the activity that uses my C++ > code. However, I discovered that if I open the TaskKiller (I'm using > Advanced Task Killer) program after that, I can always see my game as > a running program. More than that, if I run my game again, I can see > that what I allocated in the C++ program during the first run is still > there. > > I know that because of the multi-task design of the Android platform, > an application doesn't really quit when you quit it. But the > interesting thing is that if you look at the game "Angry Birds", that > one won't appear in the TaskKiller program after you play it. I'm > worrying about this issue because a game often aggressively refresh > the game loop, I think it draws the power quickly. It seems that even > I only played my game for a short time, my battery gets low very > quickly after I closed the game. > > So I'm guessing there must be something wrong in my program. Is there > any smarter way to quit an application. How did Angry Birds solve this > problem? > > Thank you. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

