2016-05-16 28 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工作。