Kalimah
Kalimah

Reputation: 11437

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 of 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.

Upvotes: 2

Views: 1754

Answers (1)

DeeV
DeeV

Reputation: 36035

Change: Toast.makeText(this, "Paused", Toast.LENGTH_LONG)

to:

Toast.makeText(this, "Paused", Toast.LENGTH_LONG).show()

Upvotes: 9

Related Questions