Retrieving past events after clearing FLAG_NOT_TOUCHABLE

I have an activity in which I want to avoid custom touch buttons in time.

I'm doing it:

WindowManager.LayoutParams params = getWindow().getAttributes(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setAttributes(params); 

It works fine, but when I return to receive touch events with:

 WindowManager.LayoutParams params = getWindow().getAttributes(); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setAttributes(params); 

I get all relatives of events for user touches for an insensitive period.

Any idea how to discard these events?

+7
source share
1 answer

I am facing the same problem, but I come to a workaround without ruining the window flag. Try the following:

 @Override public boolean dispatchTouchEvent (MotionEvent ev){ if(activityTouchable == false)return true; else return super.dispatchTouchEvent(ev); } @Override public boolean dispatchKeyEvent (KeyEvent event){ if(activityTouchable == false)return true; else return super.dispatchKeyEvent(event); } 
0
source

All Articles