Android Question Simulate touch input on other applications

macerau

Member
Licensed User
Longtime User
Please i need
A software to simulate user touch input on other applications, either tapping at a given position or dragging from one point to another.
Raul
 

DonManfred

Expert
Licensed User
Longtime User
Please i need
A software to simulate user touch input on other applications, either tapping at a given position or dragging from one point to another.
You do NOT have control over any other App.
It is not possible.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
If to talk about not own applications. Search by INJECT_EVENTS permission. But ordinary (non system) apps do not have enough rights.

If to talk about own applications, sure it's possible, for example, using intents. First app informs another that it should make some actions.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

macerau

Member
Licensed User
Longtime User
Perfect!
It was exactly what he needed.
Now I will try to create a service so I can send the command when other apps have been running.
Thank you for the tip!
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Of course, Don is right.
But two own applications are able to communicate using intents. First app activates an activity in another app and transfer "commands" in PutExtra.
Another app executes these commands (including sending input events to itself).

For example, in first app
B4X:
        Dim Intent1 As Intent
       
        Intent1.Initialize (Intent1.ACTION_MAIN, "")
        Intent1.SetComponent ("com.my.anotherapp/.main")
        Intent1.PutExtra ("Touch", "Button1")

The second app accepts "commands" in Activity_Create:
B4X:
If StartingIntent.GetExtra ("Touch") ...

Meanwhile I don't see reasons to emulate input events - it's possible to call ***_Click, ***_Touch subroutines directly.
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Normally it is not possible unless, as posted above, the running app provides an alternative known way (via intents, for instance).
If it must work with any third-party app, you could try with an accessibility service, you can send some basic actions (not all) to the focused views of the current activity.
With a rooted device, you can programatically simulate any touch event or pressing any key.
Without any of these, you can still connect with usb and perform "adb shell input ..." to simulate any input.
 
Upvote 0

macerau

Member
Licensed User
Longtime User
My goal is to search on a large map like google maps for example a specific image.
Positioning> take photo> search image within the photo and find yourself returning the coordinates of the map
 
Upvote 0
Top