Retrieving all engines using WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH

My question is directly related to this question. The answer to this question shows how you can create a ViewGroup , embed it inside a WindowManager and allow the WindowManager catch a MotionEvent through an onTouchEvent(MotionEvent event) . WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH is a flag that allows this ViewGroup to receive MotionEvent s. However, according to the documentation, this flag

... won't get a full move down / move / up

I want to know if there is a work or a way so that I can get all the touch events, including down, move and up. The proof of concept is in the Wave Launcher application, which uses the same concept, but can receive more than just one ACTION_OUTSIDE event.

+4
source share
2 answers

No, you can not, and it is very design.

Wave Launcher does not do this, it has a user interface element in which you start your touch gesture, and then, like the standard, even the dispatch, all touch events are delivered to the window of the first descending point until it is completed.

+3
source

I understand that this is an old question, but I stumbled upon it, trying to achieve something similar. I also found this, hope this is useful to someone: http://www.section465.com/code_OverlayView/

To create an overlay view, when setting up LayoutParams, you need to set the type to TYPE_SYSTEM_OVERLAY and use the FLAG_WATCH_OUTSIDE_TOUCH flag. This poses a problem because the Android documentation states: "you will not get full down / move / up, only the location of the first down, like ACTION_OUTSIDE." To get the full set of touch events you need to use the type TYPE_SYSTEM_ALERT, but this causes an overlay to capture the screen and stop interacting with other elements. The solution is to use both TYPE_SYSTEM_OVERLAY and TYPE_SYSTEM_ALERT and switch between them by changing the LayoutParams type if necessary.

+2
source

All Articles