androidandroid-overlay

How to ignore touch event and let android system handle it?


I have a service that draws an overlay view over the system. It is an utility bar. When user clicks it, it shows up. My problem is that I don't want it showing up when user click, but when user swipe it. I have a logic that can distinguish a click from an drag/swipe using onTouchListener.

The problem is: when user click it, I want to ignore the touch and let the android system consumes it. When user swipe, I want to consume the event and dont let android consume it, because I will make my utility bar show up.

How to achieve this? I am on API 25(android N).


Solution

  • Simple answer: You can't.

    Once overlay view receives touch event, its considered consumed and it's never propagated further.

    This is mostly a security measure, since you can record and distunguish X, Y coordinates it would allow implementation of keyloggers or other click blocking/spoofing code.