微信扫一扫

028-83195727 , 15928970361
business@forhy.com

adb shell 如何选择特定的设备?

adb-device,adb-shell2016-06-22

开篇

手机冲着电,开着安卓模拟器,想给模拟器发送命令,怎么办呢?怎么办呢?

解决之法

其实这个一查,stackoverflow或者百度谷歌一大把,比如这个“http://stackoverflow.com/questions/14654718/how-to-use-adb-shell-when-multiple-devices-are-connected-fails-with-error-mor”,不过呢,当然要配图才能更加清晰明了了。下面就看下配图版解答。

进入正题:

1. adb devices 显示都有哪些设备连接

2. adb -s emulator-5556 shell {command} 发送指定命令

比如最近在折腾React Native, 要显示开发者菜需要点击菜单键或者发送input keyevent 82,那么就可以使用命令:adb -s emulator-5556 shell input keyevent 82,如下图:

模拟器也会立刻给我们反应:

3. adb -s emulator-5556 shell 进入shell命令行

2中我们是每次发送命令都需要指定是哪个设备,这无疑是非常麻烦的。我们可以先通过adb -s {emulator-name} shell 进入指定模拟器的shell。如下图所示:

然后我们就可以畅快输入命令了:

最后使用exit命令退出。
整个过程如下图: