Display a Message on Closing an Activity
So, when the user force closes an activity, I want to display a custom message (Toast) to the user. Any suggestions? I tried putting the Toast in my onPause()
/ onStop()
开发者_如何学编程methods, but they cause the program to crash.
And no, I'm not trying to spam the user with messages everytime he/she force closes an activity. I just want to display the Toast when a particular activity is closed.
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
toast(getString(R.string.exit_msg), Toast.LENGTH_SHORT);
}
return super.onKeyDown(keyCode, event);
}
精彩评论