Search code examples
androidkeyandroid-browsersimulate

Simulate key press from an android service


I want to make an android service that would let me simulate keypress to fill fields on a web page when receiving an intent. Is this possible in any way or maybe through a different process (Not by simulation keypress?).

For example an example of what I would want to be able to do.

The user is on his tablet and has selected a field on a web page. For any bluetooth device discovered, fill the field with that id.

IS there a way to do it by calling an intent of the web browser or something like that?

Thanks

EDIT : figured my example was pretty bad.

Here is what I really want to do

When a nfc tag is detected on the phone, read the nfc tag ID, simulate keypress events of the id tag on whatever the focus is at the moment on the phone

Example : I'm on google focused on the search field and I put a nfc tag on the phone, the phone types the Nfc tag id on the google search field and voila


Solution

  • if you really want to simulate keyevents, you can use system calls:

    input keyevent <keycode>