开发者

how to display toast message before onPause() in android?

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜