I am attempting to display a toast message before the activity pauses by overriding onPause method with this code:
@Override
protected void onPause() {
Toast.makeText(this, "Paused", Toast.LENGTH_LONG);
super.onPause();
}
according to this http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle activity will not be paused until this method is returned:
"Implementations o开发者_StackOverflow社区f this method must be very quick because the next activity will not be resumed until this method returns."
However toast message is not displayed at all.
Change:
Toast.makeText(this, "Paused", Toast.LENGTH_LONG)
to:
Toast.makeText(this, "Paused", Toast.LENGTH_LONG).show()
精彩评论