Can an Android Toast be longer than Toast.LENGTH_LONG?

user268481 picture user268481 · Feb 8, 2010 · Viewed 188.7k times · Source

When using setDuration() for a Toast, is it possible to set a custom length or at least something longer than Toast.LENGTH_LONG?

Answer

FeelGood picture FeelGood · Feb 22, 2011

If you dig deeper in android code, you can find the lines that clearly indicate, that we cannot change the duration of Toast message.

 NotificationManagerService.scheduleTimeoutLocked() {
    ...
    long delay = immediate ? 0 : (r.duration == Toast.LENGTH_LONG ? LONG_DELAY : SHORT_DELAY);
    }

and default values for duration are

private static final int LONG_DELAY = 3500; // 3.5 seconds
private static final int SHORT_DELAY = 2000; // 2 seconds