通过命令发送按键到Android系统
来源:互联网 发布:tensorflow 手写识别 编辑:程序博客网 时间:2024/05/08 02:53
有时PAD或者VR机器上没有物理按键,但却想给应用发送这样的按键来测试应用程序是否OK,可以通过串口或者ADB执行以下命令达到目的:
input keyevent 键值名称
举几个例子:
模拟人的手指触摸HOME按键退到Launcher主界面:input keyevent HOME
模拟Android电视盒的遥控器发送MENU按键:input keyevent MENU
模拟物理键盘按向左键:input keyevent DPAD_LEFT
那后面的键值名称该写什么呢,看这个文件就好了:android/frameworks/base/core/java/android/view/KeyEvent.java,随便截取一段如下:
107 public static final int KEYCODE_1 = 8;
108 /** Key code constant: '2' key. */
109 public static final int KEYCODE_2 = 9;
110 /** Key code constant: '3' key. */
111 public static final int KEYCODE_3 = 10;
112 /** Key code constant: '4' key. */
113 public static final int KEYCODE_4 = 11;
114 /** Key code constant: '5' key. */
115 public static final int KEYCODE_5 = 12;
116 /** Key code constant: '6' key. */
117 public static final int KEYCODE_6 = 13;
118 /** Key code constant: '7' key. */
119 public static final int KEYCODE_7 = 14;
120 /** Key code constant: '8' key. */
121 public static final int KEYCODE_8 = 15;
122 /** Key code constant: '9' key. */
123 public static final int KEYCODE_9 = 16;
124 /** Key code constant: '*' key. */
125 public static final int KEYCODE_STAR = 17;
126 /** Key code constant: '#' key. */
127 public static final int KEYCODE_POUND = 18;
128 /** Key code constant: Directional Pad Up key.
129 * May also be synthesized from trackball motions. */
130 public static final int KEYCODE_DPAD_UP = 19;
131 /** Key code constant: Directional Pad Down key.
132 * May also be synthesized from trackball motions. */
133 public static final int KEYCODE_DPAD_DOWN = 20;
134 /** Key code constant: Directional Pad Left key.
135 * May also be synthesized from trackball motions. */
136 public static final int KEYCODE_DPAD_LEFT = 21;
137 /** Key code constant: Directional Pad Right key.
138 * May also be synthesized from trackball motions. */
139 public static final int KEYCODE_DPAD_RIGHT = 22;
140 /** Key code constant: Directional Pad Center key.
141 * May also be synthesized from trackball motions. */
142 public static final int KEYCODE_DPAD_CENTER = 23;
143 /** Key code constant: Volume Up key.
144 * Adjusts the speaker volume up. */
145 public static final int KEYCODE_VOLUME_UP = 24;
146 /** Key code constant: Volume Down key.
147 * Adjusts the speaker volume down. */
148 public static final int KEYCODE_VOLUME_DOWN = 25;
149 /** Key code constant: Power key. */
150 public static final int KEYCODE_POWER = 26;
- 通过命令发送按键到Android系统
- 通过adb shell 向android系统发送虚拟按键
- 通过Android keyevent 向系统发送命令
- 在Android系统中发送模拟按键
- Android: 发送虚拟按键
- 如何通过发送到Soft Key Bar上的消息捕获一些硬按键
- 获取按键值应用数码进行显示同时通过串发送到PC上进行显示
- 通过adb发送按键输入事件
- Android发送虚拟按键(转)
- Android 模拟按键发送消息
- 命令模拟android 按键
- Android系统增加按键
- 使用adb shell命令发送按键
- android通过base64encode方式发送图片到服务端
- android通过base64encode方式发送图片到服务端
- 通过webservice 将图片发送到Android客户端
- Android 通过adb shell am broadcast发送广播 adb命令
- Android 通过按键旋转屏幕
- SpringMVC+fastjson配置
- CentOS yum源配置
- Aidl实现应用程序之间的 通信
- tomcat参数引发后台建立影子任务
- 友盟+推送
- 通过命令发送按键到Android系统
- c++
- Spring学习笔记之通过XML装配Bean的一些细节
- Hibernate相关
- Android studio 使用ndk开发JNI
- 设置NavigationBar导航栏中返回按钮(BackBarButtonItem)和BarButtonItem文字
- Hadoop2.6.0防止误删机制-Trash
- 金融科技之量化文本研究框架
- cpu对编程的影响