The Kindle Fire has a bar at the bottom that includes a "home" button and a "back" button.
When I click the "back" button, my app's "onPause()" event is invoked.
When I click the "home" button, my app crashes. An Android dialog box is displayed. It says my app has stopped unexpectedly. I am presented with a "force close" button.
Sooooo what event do I need to be handling to prevent this. This only happens on my app, not the ones I downloaded, so yeah, it's me, lol.
Edit
As per this web page, I added events and toasts to the app just to gain some insight into how things work. When I click the Back button, I see the toasts produced by the onPause(), onStop(), and onDestroy() methods. When I click the Home button, there are no toasts, just the crash.
RESOLUTION
Akhil suggested I look at the logcat. I don't run the emulator since my machine seems understrength for Android development (or perhaps I expect too much from the emulator); it takes forever to start it up. Anyway, after figuring out how to run the emulator (and look at the logcat for the first time, ha) I saw that I was throwing an exception related to serialization. I'm off to solve it now. Thanks Akhil for the kick in the right direction!
Ah, and the emulator did display the onPause() toast when I clicked Home, so reality is still functioning as expected.
FINAL
The error was related to the serialization I added to make the onSaveInstanceState(Bundle savedInstanceState) method work. Basically, my app (and old game I converted to android) wasn't serializable, therefore this code in onSavedInstanceState() would not compile:
savedInstanceState.putSerializable(GAME, game);
'game' is innocuous, so I added "implements Serializable" to Game's class definition. However, I neglected to add the same to a private class within Game. This is what was causing the exception.
When you click the "back" button, your app's "onPause(), onStop(),onDestroy()
" events will be invoked.
When you click the "home" button, your app's "onPause(), onStop()
," events will be invoked.
( This is a general scenario, assuming)
Put log statements in your onPause(), onStop()
and see where you are getting the error.