Android Toast message not appearing on first request
-
08-10-2019 - |
Question
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();
Solution
Make sure you are properly initializing the variable msg.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow