Toasts overlap issue on Oreo (8.1) Toasts overlap issue on Oreo (8.1) android android

Toasts overlap issue on Oreo (8.1)


private static final int TIME_DELAY = 4000;private static long lastToastShowTime = 0;showToast(final String msg, final Context ctx){    final long pastTime = System.currentTimeMillis() - lastToastShowTime;    if(pastTime > TIME_DELAY ){        Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show();        lastToastShowTime = System.currentTimeMillis();     }else{        final long delay = TIME_DELAY - pastTime;        lastToastShowTime = System.currentTimeMillis() + delay;        postDelayed(new Runnable(            @Override            public void run() {               try{                  Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show();               catch(Exception e){                  Log.e("TOAST_NOT_SHOWED", "Toast not showed: " + msg, e);               }            }        ), delay);    }}