Answers for "how to make custom toast visible for 20 seconds android"

0

how to make custom toast visible for 20 seconds android

final Toast toast = Toast.makeText(getApplicationContext(), "The following message will disappear in half second", Toast.LENGTH_SHORT);
    toast.show();

    Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
           @Override
           public void run() {
               toast.cancel(); 
           }
    }, 500);
Posted by: Guest on February-22-2021
0

how to make custom toast visible for 20 seconds android

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.

If you want to display a message to the user for longer, consider a Status Bar Notification. Status Bar Notifications can be programmatically canceled when they are no longer relevant.
Posted by: Guest on February-22-2021

Code answers related to "how to make custom toast visible for 20 seconds android"

Browse Popular Code Answers by Language