Pol Hallen
Pol Hallen

Reputation: 1872

toast only in my activity

I've an app that periodically show same toasts also when app goes to background. So when I use other app I see toasts of my app. How allow show toasts only in my activities?

Toast.makeText(getApplicationContext(), "level",
Toast.LENGTH_LONG).show();

Upvotes: 0

Views: 647

Answers (2)

Stefan de Bruijn
Stefan de Bruijn

Reputation: 6319

You could take a look at the Croutons library, which addresses exactly the problem with Toasts showing out of their context.

Here you can find an explanation and where to download it.

Upvotes: 3

Stephane Mathis
Stephane Mathis

Reputation: 6622

You can't tell your Toast to be visible only if the activity is visible. You should rather avoid to call the show() function when your app is running in background.

Upvotes: 3

Related Questions