Android overlay to grab ALL touch, and pass them on? Android overlay to grab ALL touch, and pass them on? android android

Android overlay to grab ALL touch, and pass them on?


Found this documentation that pretty much states that it's not possible to do both:Android : Multi touch and TYPE_SYSTEM_OVERLAY

They discuss workarounds but I don't think any of them will actually work for exactly what I'm trying to do. Both given the events to the underlying app, and being able to snoop them to act upon them for myself.

To create an overlay view, when setting up the LayoutParams you need to set the type to TYPE_SYSTEM_OVERLAY and use the flag FLAG_WATCH_OUTSIDE_TOUCH. This presents a problem because as the Android documentation states: "you will not receive the full down/move/up gesture, only the location of the first down as an ACTION_OUTSIDE." In order to receive the full array of touch events you need to use the TYPE_SYSTEM_ALERT type, but this causes the overlay to take over the screen and stop interaction with other elements.

Anyone wants to disagree I'd love to hear good news :-D


You can use the GestureOverlayView, if you want to hide the lines it draws you can set the color to Transparent #00000000 so it doesn't show up, and then you can capture all touches, and gestures.

http://developer.android.com/resources/articles/gestures.html


I was looking for the same thing.

This flag does the trick for me FLAG_NOT_TOUCH_MODAL

Works on Android 7 and 8 setup as below.

The only action I've implemented so far is a touch to close the overlay window.

I also used code from here Example System Overlay Code on Github which was needed to get the events.

By the way Google Maps does a really nice job with this on Android 8. You can drag their overlay window around, resize it or close it. And all other apps work fine while it's up.

    var type = 0    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)    {        type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT    }    else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)    {        type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY    }    var flags = FLAG_NOT_TOUCH_MODAL    mOverlayLayoutParams = WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, type, flags, PixelFormat.TRANSLUCENT)