How to block UI for some seconds in android?

android, wait

Solution

You can override `dispatchTouchEvent` and stop the call to `super.dispatchTouchEvent(ev);` Any touch event will have to go through this method before it is handled.

Set a boolean that you control and use it in the method to determine whether you wish to block control.

private boolean stopUserInteractions = false;

public boolean dispatchTouchEvent(MotionEvent ev) {
    if (stopUserInteractions) {
        return true;
    } else {
        return super.dispatchTouchEvent(ev);
    }
}

Problem

How can i block UI from all interactions for some seconds by user in Android? I would like to know, how to do this with some delay timing like `wait(5000);`

Original source