2016-05-16 117 views
2

我试图启用禁用蓝牙android设备上使用命令行。android enable通过命令行禁用蓝牙

我可以用

adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE

启用它,但它会提示用户 '允许' 或 '拒绝'。

我也看到有选项以启动BLE设置第一像

adb shell am start -a android.settings.BLUETOOTH_SETTINGS

,然后启用禁用adb shell input keyevent **

但它不会是设备无关。

回答

8

要启用:

adb shell service call bluetooth_manager 6 

要禁用:

adb shell service call bluetooth_manager 8 
+0

启用正在工作,但禁用不起作用 –

+0

这两个命令都不适用于我。我正在使用三星S4设备和它的Android 4.2。 – Codelearner

+0

我们正试图启用和禁用蓝牙,我们使用ADB命令 启用开始我们的自动化测试之前 亚行外壳服务调用bluetooth_manager 6 禁用 亚行外壳服务调用bluetooth_manager 9 我们正在使用此命令的蓝牙状态 亚行外壳设置获得全局bluetooth_on 是否有任何其他解决方案来启用和禁用使用APPIUM java的蓝牙,因为这些命令在某些设备中工作,但不是在所有设备中工作。任何解决方案? 在Android 5(Lollipop)中工作的命令相同, – alk1985

2

要运行在以前的评论中列出的命令,你必须是根:

adb root

启用:

adb shell service call bluetooth_manager 6

禁用:

adb shell service call bluetooth_manager 8

1

要启用:

adb shell service call bluetooth_manager 6 

要禁用:

adb shell service call bluetooth_manager 9 

测试,在三星Galaxy S7工作。