What is the duration of a Toast LENGTH_LONG and LENGTH_SHORT
The Toast.LENGTH_SHORT
and Toast.LENGTH_LONG
are just flags.
You can find here the official android source where these flags are defined:
public class NotificationManagerService extends SystemService {
static final int LONG_DELAY = PhoneWindowManager.TOAST_WINDOW_TIMEOUT;
/** Amount of time (in milliseconds) a toast window can be shown. */
//public static final int TOAST_WINDOW_TIMEOUT = 3500; // 3.5 seconds
static final int SHORT_DELAY = 2000; // 2 seconds
private void scheduleDurationReachedLocked(ToastRecord r)
{
mHandler.removeCallbacksAndMessages(r);
Message m = Message.obtain(mHandler, MESSAGE_DURATION_REACHED, r);
int delay = r.duration == Toast.LENGTH_LONG ? LONG_DELAY : SHORT_DELAY;
//....
mHandler.sendMessageDelayed(m, delay);
}
}
Answered here. Like you mentioned Toast.LENGTH_SHORT
and Toast.LENGTH_LONG
are not in ms but 0 or 1.
The actual durations are:
private static final int LONG_DELAY = 3500; // 3.5 seconds
private static final int SHORT_DELAY = 2000; // 2 seconds