Android Question Send Input

GiovanniO

Member
Since the SendInput library is no longer supported in Android 13+, does anyone have an update or know of a method to generate a tap within my app?

Thanks everyone for your responses. Best regards.
 

zed

Well-Known Member
Licensed User
If I understand correctly, you want to simulate a physical key?
There's no direct method to simulate a keystroke on the keyboard like you could with system events or input injections in lower-level environments.
To simulate a real keystroke (like KEYCODE_ENTER), you'd have to use advanced Java APIs or accessibility services, which aren't directly supported by B4A without root or special permissions.
If you specify exactly what you want to simulate (e.g., typing "OK," validating a field, triggering an action), there might be a more targeted and clean solution in B4A.
 
Upvote 0

GiovanniO

Member
If I understand correctly, you want to simulate a physical key?
There's no direct method to simulate a keystroke on the keyboard like you could with system events or input injections in lower-level environments.
To simulate a real keystroke (like KEYCODE_ENTER), you'd have to use advanced Java APIs or accessibility services, which aren't directly supported by B4A without root or special permissions.
If you specify exactly what you want to simulate (e.g., typing "OK," validating a field, triggering an action), there might be a more targeted and clean solution in B4A.
Thanks for your answer. I don't want to simulate keystrokes; I want to simulate a tap (click) on the screen. Previously, the Accessibility library worked for that; now, it doesn't fire the tap event. I don't know if this has anything to do with the new Android APIs.
 
Upvote 0

zed

Well-Known Member
Licensed User
Simulating a real keystroke is not directly supported for Android security reasons.
You can manually trigger events like Button1_Click or Panel1_Touch in your code.
This doesn't simulate a real physical touch, but it allows you to execute the same code as if the user had clicked.
To simulate system interactions (such as a real tap on the screen), you need to use Accessibility Services.
These methods require special permissions.

Android prevents apps from simulating physical taps or clicks without explicit permission (such as Accessibility Services).
Any attempt to fully simulate a touch tap requires elevated permissions and may not be accepted on the Play Store.
 
Upvote 0

GiovanniO

Member
Simulating a real keystroke is not directly supported for Android security reasons.
You can manually trigger events like Button1_Click or Panel1_Touch in your code.
This doesn't simulate a real physical touch, but it allows you to execute the same code as if the user had clicked.
To simulate system interactions (such as a real tap on the screen), you need to use Accessibility Services.
These methods require special permissions.

Android prevents apps from simulating physical taps or clicks without explicit permission (such as Accessibility Services).
Any attempt to fully simulate a touch tap requires elevated permissions and may not be accepted on the Play Store.
Thanks again for your answer. I don't have any issues with permissions because I don't want to publish it on the Play Store. All I need is for the Tap event to work correctly. I tried the Accessibility library, but it doesn't generate the Tap event (the action is called DispatchGesture). I don't know if it's due to new Android restrictions, so I opened this thread. I hope someone can give me some guidance on the issue.
 
Upvote 0
Top