What is Android Toast.LENGTH_SHORT and Toast. LENGTH_LONG durations

Toasts are used in android to display Notifications. When .show() method is called they fade-in and stay for a while and fade-out depending upon what time in milliseconds we set for a Toast using setDuration() method.

We can only specify two values for the duration of Toast those are


Do you know that even if we can set any integer value to setDuration(), the toast message will only be displayed for 1.5secs (ie Shot period) or 3secs (long period).

Both of these variables are Flags with value 0 and 1 respectively.

The reason if you see: NotificationManagerService.java code which is called to display Toast,

private void scheduleTimeoutLocked(ToastRecord r, boolean immediate)
        Message m = Message.obtain(mHandler, MESSAGE_TIMEOUT, r);
        long delay = immediate ? 0 : (r.duration == Toast.LENGTH_LONG ? LONG_DELAY : SHORT_DELAY);
        mHandler.sendMessageDelayed(m, delay);


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

Hence there is no way you can change the value of LENGTH_LONG or LENGTH_SHORT. The only way to display Toast for a longer period is through some java code tweaking!

Recent Posts:

Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.