Android Question [SOLVED] Background Service --> Tap on screen

Claudio Parmigiani

Member
Licensed User
Hi all,
I have a Scheduled Service (basically a timer ticking every x minutes), already running in background.
This app does not have any main screen, after launch it's just a Service.

Question:
I need this Service to <<simulate>> a tap on the screen on to specific coordinates x,y.

I do not need any screen adaptation, it has to run on a specific display size only.

Do you have any suggestion on how to do that?

Thank you very much for your support, as usual.

Best Regards,
Claudio.
 

DonManfred

Expert
Licensed User
I need this Service to <<simulate>> a tap on the screen on to specific coordinates x,y.
I do not need any screen adaptation, it has to run on a specific display size only.
Do you have any suggestion on how to do that?
AFAIK android does not allow apps to simulate clicks/taps
 
Upvote 0

DonManfred

Expert
Licensed User
Upvote 0

DonManfred

Expert
Licensed User
Here a version including the jump to google play if it is not installed
B4X:
    Dim pm As PackageManager
    Dim i As Intent=pm.GetApplicationIntent("org.zwanoo.android.speedtest")
    If i.IsInitialized Then
        StartActivity(i)
    Else
        Dim Intent1 As Intent
        Intent1.Initialize(Intent1.ACTION_VIEW, "market://details?id=org.zwanoo.android.speedtest")
        StartActivity(Intent1)
    End If
 
Upvote 0

Claudio Parmigiani

Member
Licensed User
Oh yes, I've just read your note:

BTW: This code does nothing more than to send out an intent.
It does not simulate a tap

I'll try to contact the author, in case of no answer I'll build a robot with a conductive finger...
:)

Thanks again and have a nice weekend,
ciao,
C.
 
Upvote 0

Claudio Parmigiani

Member
Licensed User
This post just to say that I solved.
Install first b4aRootCmd library (and root your phone)

B4X:
' simulate tap on coordinates 100, 200
Dim rc As RootCmd
If rc.haveRoot Then
        rc.execRootCmd("input tap 100 200") '
End If

If you need also to simulate the "back" key:

B4X:
'simulate tap on "back" key
rc.execRootCmd("input keyevent KEYCODE_BACK")

Thanks to everybody,
ciao,
C.
 
Upvote 0
Top