I am developing an application in which I have to implement this part . I have to implement motionevents (like action down , action up) without the touch from user.
Asked
Active
Viewed 427 times
1 Answers
0
Obtain a new MotionEvent
and use dispatchTouchEvent()
.

Dheeraj Vepakomma
- 26,870
- 17
- 81
- 104
-
i didn't get your point , can you please provide me a link or sample code ? – Ahmed Apr 01 '12 at 14:15
-
one more thing i want to do this through service not from an activity – Ahmed Apr 01 '12 at 14:22
-
What is your requirement? Are you developing some sort of automated UI testing service? – Dheeraj Vepakomma Apr 01 '12 at 14:24
-
I am developing Bluetooth HID driver for mouse . What i have done so far is establish a Bluetooth connection between Bluetooth mouse and android phone . For i have use intent service for establish connection . Now this service is broadcasting mouse key events and x,y values . IME service which i have created has broadcast receiver , now from here i want to simulated the mouse movements through motion event . So when user press left click on mouse , on android screen it select the respective object , that is why i want to simulate action down etc events . – Ahmed Apr 01 '12 at 14:36
-
2I'm afraid, that may not be possible due to security restrictions as per [this discussion](http://stackoverflow.com/a/5240821/165674). Perhaps if your app is signed with the System certificate, I guess you MAY be able to accomplish it somehow. – Dheeraj Vepakomma Apr 01 '12 at 14:51
-
you are saying that i need to have root permissions for this ? – Ahmed Apr 01 '12 at 15:06
-
i have no idea regarding system certificate . – Ahmed Apr 01 '12 at 15:08
-
@user1155908 Check [this post](http://stackoverflow.com/questions/8342049/android-system-certificate). – Dheeraj Vepakomma Apr 01 '12 at 18:21
-
@Ahmed can you guide me to achieve the same function as my app would be running in background but I want to perform clicks on another apps or launcher of the android. – skygeek Jun 26 '13 at 09:19
-
@skygeek excellent work done by this guy http://www.pocketmagic.net/2013/01/programmatically-injecting-events-on-android-part-2/#.UeEvDztJOSo . – Ahmed Jul 13 '13 at 10:45
-
@Ahmed yeah it's good help there but still it is not working on my rooted htc phone. – skygeek Jul 15 '13 at 03:43