Skip to content Skip to sidebar Skip to footer

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(); Han

Solution 1:

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();
}

Solution 2:

There are only two possible Toast durations: short (2 sec) and long (3.5 sec).

If you need a more persistent message, use a dialog or include the message in your layout.

One easy way to make context-sensitive messages in your layout with custom durations is the Crouton library.

Solution 3:

Take a look at this answer.

The values of LENGTH_SHORT and LENGTH_LONG are 0 and 1. This means they are treated as flags rather than actual durations so I don't think it will be possible to set the duration to anything other than these values.

Solution 4:

finalToasttag= Toast.makeText(getBaseContext(), "YOUR MESSAGE",Toast.LENGTH_SHORT);

tag.show();

newCountDownTimer(9000, 1000) {

    publicvoidonTick(long millisUntilFinished) {tag.show();}
    publicvoidonFinish() {tag.show();}

}.start();

See Similar Question and answer there.

Solution 5:

Toasts are not meant to be used like that. Toasts are transient and Android has defined them to be either SHORT or LONG.

If you want, you can create a Dialog than completely emulated the appearance of a Toast, but I would use a dismissable dialog or a notification as it could be frustrating for the user to have a Toast showing for a whole minute without the possibility to dismiss it.

Post a Comment for "Set Android Toast Duration To Be Really Long (e.g., 1 Minute)"