Simulating touches onto an activity of another application

若如初见. 提交于 2019-12-08 08:22:58

问题


Is it possible to simulate touch events in Android from one app to another app? Perhaps use a service or an invisible activity with SYSTEM_ALERT property to receive the input touches then simulate them to another activity of another application which is directly below the transparent activity of your application. Is this possible?

[UPDATE]

Taking FoamyGuy's answer into account, is it possible to have an invisible SYSTEM_ALERT activity to filter out certain touch events? I know you can revoke input for the activity. Is it possible to revoke selective input? Or do I still have to create a custom ROM?


回答1:


Yes it is, if your app is signed with the platform certificate you may use the INJECT_EVENTS permission and inject events on any application:

http://developer.android.com/reference/android/Manifest.permission.html#INJECT_EVENTS




回答2:


It is not possible. This would be cause for major security concern. You can use the Instrumentation APIs to inject events into your own Activities, but you cannot inject events into any Activities that are not your own.

The ability to do so would make it trivial to circumvent the necessity for user interaction to do certain things (i.e. install/uninstall apps).

If you want to be able to do it you'll have to modify the system on your own device to enable it.



来源:https://stackoverflow.com/questions/16736595/simulating-touches-onto-an-activity-of-another-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!