admin管理员组文章数量:1415491
I'm working on an Android project where I need to count the number of clicks or screen touches that occur on an underlying application, even when my app is running in the foreground.
Here's the scenario:
- My app is running in the foreground.
- Another app (e.g., the calculator app) is running in the background, visible beneath my app.
- I need to detect and count the number of times the user touches the screen, even if those touches are technically interacting with the underlying app.
I've tried several approaches, including:
- Foreground Services: These allow my app to run in the foreground, but they don't seem to provide a way to capture touch events on other apps.
- Accessibility Services: While powerful, I'm not sure if they are the right tool for this specific task, as I don't need to interact with the underlying app's UI elements, just count the touches.
- WindowManager and Overlays: I've created a transparent overlay using
WindowManager
andSYSTEM_ALERT_WINDOW
permission, but I'm struggling to capture touch events that are intended for the underlying app. - TouchInterceptor : I created a TouchInterceptor class that extends View. I added this class to the windowManager with 0 width and 0 height. I tried to catch touch events with onTouchEvent method. But onTouchEvent method is not called.
I'm looking for a way to achieve this without requiring root access or modifying the underlying app.
Here are my specific questions:
- Is it possible to capture touch events that occur on an underlying app from a foreground app in Android?
- If so, what are the recommended approaches or techniques to achieve this?
- Are there any specific Android APIs or permissions that I should be using?
- Is there a way to detect touch events without interfering with the underlying app's functionality?
- Why is onTouchEvent method not called?
Any guidance or code examples would be greatly appreciated.
Thanks in advance!
本文标签:
版权声明:本文标题:accessibility - How to Count Clicks or Screen Touches on an Underlying App from a Foreground App in Android? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745178998a2646377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论