How can we simulate the user's click on the screen?

bsnqt

Active Member
Licensed User
Longtime User
Hi experts,

I try to find out how we can simulate the user's click (and long click) on the display screen of our Android phone, programmatically, on a given point (x,y).

I believe it can be done but did not find out in the forum after several searches (actually, I don't know which valid key word to be used). Would you please advise me or a good code snippet or at least a direction or link how to do this.

Thank you very much.

Best regards,
bsnqt
 
Last edited:

WAZUMBi

Well-Known Member
Licensed User
Longtime User
I use the panel touch sub to trap the location of the touch on the screen

B4X:
Sub pnl_Touch (Action As Int, X As Float, Y As Float)

select Action 
case Activity.ACTION_DOWN 
                  
case Activity.ACTION_UP
      
Case Activity.ACTION_MOVE   

End Select
end sub
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Hi WAZUMBi,

Thanks for your answer, that's great, but this is not what I meant. I think your solution does work only when my app is already displayed on the screen (i.e. the user can see your panel). Or please correct if I am wrong.

What I want is even when my app is not "visible" on the screen, you can still be able to "send" a click, for example from a service module, to the phone's screen (not to the panel of the app), at any given point (x, y) and programmatically (not need the user to make a "physical" click).

I know that we can do this with .NET when I worked with some Window Mobile applications (with Visual Basic).

Any more idea, please.

Thank you again.

Best
 
Last edited:
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
I think it's impossible with Android.
 
Upvote 0
Top