Toast does not show on screen

Viewed 161

I am sorry if it is a too simple question. I have searched everywhere, but could not find a solution. For about 3 days Toast does not show up on my app. I tried to do a lot of things.

  • Change makeText(this) to makeText(getApplicationContext()) or makeText(getBaseContext())

  • Change position of the Toast and tried other solution on StackOverflow, but it did not appear.

Here is the code

Toast.makeText(this, "Great", Toast.LENGTH_SHORT).show();
3 Answers

Try this. Toast.makeText(getApplicationContext(), "Test string", Toast.LENGTH_SHORT).show();

The most important one , make sure your Android Notifications are on for your app, else the Toast will not be shown.

Try this :

Toast.makeText(yourActivity.this, "Try Toast", Toast.LENGTH_SHORT).show();

And make sure you use the codes in the correct line.

Here is an example

Toast.makeText(getActivity(), "This is my Toast message!", Toast.LENGTH_LONG).show();

Related