简体   繁体   中英

Android: simulate a physical button press of keyboard input

This might be a bit of an ambiguous question but I'll do my best at describing what I want to do. I need to make a service that will trigger a physical button press or input code to the currently active application. I'm trying to make a mapper for the Xperia Play touch pads so they can be used with apps and games that don't support them but mapping each axis corner to a physical keyboard key or input.

I can imagine such a feature would be a security risk to include in the standard Android SDK, although I may be wrong in which case there might be some kind of Intent or Receiver to handle those events.

If there isn't, does anyone know how I could go about doing what I want to do?

Try sendkey command in you adb shell.

You cannot do it in application yet.

You cannot do this in a normal App, but you have two other options depending on your needs:

  • Android SDKs MonkeyRunner lets you automate input
  • Using root to directly manipulate the keyboard events in android; I know that there are tools for linux with Xorg, but I'm not sure if they will work on android: xvkbd or xdotool

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM