1

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?

2 Answers2

2

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);
}
Bojan Kseneman
  • 15,488
  • 2
  • 54
  • 59
0

Check if it is visible or not.

if (toast == null || toast.getView().getWindowVisibility() != View.VISIBLE) {
    // Toast isn't shown //
}
Chris Stillwell
  • 10,266
  • 10
  • 67
  • 77