Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Android Toast duration to be really long (e.g., 1 minute)

I try to set my Toast show duration like 1minute. I try this:

  final Toast toast = Toast.makeText(getApplicationContext(), "MESSAGE", Toast.LENGTH_LONG );
  toast.show();

    Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
               @Override
               public void run() {
                   toast.cancel(); 
                   }
            }, 60000);

Thanks for your help.

like image 858
Merv Avatar asked Dec 05 '22 07:12

Merv


1 Answers

Since LENGTH_SHORT is 2 seconds (and LENGTH_LONG is 3.5 seconds), try this:

for (int i=0; i < 30; i++)
{
    Toast.makeText(this, "MESSAGE", Toast.LENGTH_SHORT).show();
}
like image 68
Phantômaxx Avatar answered Dec 10 '22 11:12

Phantômaxx