开发者

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

开发者 https://www.devze.com 2023-04-01 01:30 出处:网络
I am attempting to display a toast message before the activity pauses by overriding onPause method with this code:

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

精彩评论

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