Grant
Grant

Reputation: 11356

Android Toast message not appearing on first request

i am having a problem whereby when i open my app from the main screen, whether for the first time or not, when i click one of the buttons to show a toast message, the first time i click the button the toast message doesnt appear but it does appear for the 2nd and every subsequent click. if i then go home and launch my app again i have to wait for the 2 click to see a toast. does anyone know why this may be?

this is how i am using the toast class..

Context context = getApplicationContext();
int duration = Toast.LENGTH_SHORT;

Toast toast = Toast.makeText(context, msg, duration);
toast.show();

Upvotes: 3

Views: 1350

Answers (1)

Mudassir
Mudassir

Reputation: 13174

Make sure you are properly initializing the variable msg.

Upvotes: 1

Related Questions