You haven't given context in your code. Try this:
Toast.makeText(MainActivity.this, "Toast message", Toast.LENGTH_SHORT).show();
If you want to make your Toast appear for a long time then replace LENGTH_SHORT with LENGTH_LONG.
Toast
LENGTH_SHORT
LENGTH_LONG
Read more about Toast and its alternatives at developer.android.com/guide/topics....
Thanks Dibas
You can also use getApplicationContext() instead of MainActivity.this
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You haven't given context in your code. Try this:
If you want to make your
Toast
appear for a long time then replaceLENGTH_SHORT
withLENGTH_LONG
.Read more about
Toast
and its alternatives at developer.android.com/guide/topics....Thanks Dibas
You can also use getApplicationContext() instead of MainActivity.this