Reputation: 1872
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
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
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