Skip to content Skip to sidebar Skip to footer

How To Check If The Toast Have Dismissed Or Not

i want to check if the toast have dismissed or not ,because user click the mouse the toast is show,but may me the user continuous click,so i need to check,i cannot use the dial

Solution 1:

Toasttoast=null;
if (toast == null || toast.getView().getWindowVisibility() != View.VISIBLE) {
    toast = Toast.makeText(getApplicationContext(),
        "Text", Toast.LENGTH_SHORT);
    toast.show();
}

Check if the toast is visible before you show it again.

Solution 2:

Toasttoast= yourToastCreationCode();

if (null == toast.getView().getWindowToken())
{
    yeahToastIsInvisible();
}

Solution 3:

Based on Denis answer, but worked better for me.

Toast t;
t=Toast.makeText(getActivity(), "test", Toast.LENGTH_LONG);
t.show;

if (t.getView().isShown())
{
   //visible
}

Post a Comment for "How To Check If The Toast Have Dismissed Or Not"