I create a toast and display it. What i want is to display some text on screen once the toast has disappeared.
is there a way to accomplish this?
I create a toast and display it. What i want is to display some text on screen once the toast has disappeared.
is there a way to accomplish this?
Toast messages do not have any interfaces to tell you when they disapper, but their default length of how long they are displayed is known.
private static final int LONG_DELAY = 3500; // 3.5 seconds
private static final int SHORT_DELAY = 2000; // 2 seconds
Use this to do the trick
private void doSometingAfterToast(int toastLength){
new android.os.Handler(getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
doSomething();
}
}, toastLength);
}
Check if it is visible or not.
if (toast == null || toast.getView().getWindowVisibility() != View.VISIBLE) {
// Toast isn't shown //
}