android enable disable bluetooth via command line

2019-01-18 15:16发布

I am trying to enable disable bluetooth on android device using command line.

I can enable it using

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

But it prompts user to 'allow' or 'deny'.

I also see there is option to launch ble settings first like

adb shell am start -a android.settings.BLUETOOTH_SETTINGS

and then enable disable adb shell input keyevent **

But it won't be device independent.

4条回答
疯言疯语
2楼-- · 2019-01-18 16:07

To enable:

adb shell service call bluetooth_manager 6

To disable:

adb shell service call bluetooth_manager 8
查看更多
Evening l夕情丶
3楼-- · 2019-01-18 16:10

To run commands listed in previous comment, you need to be root:

adb root

Enable:

adb shell service call bluetooth_manager 6

Disable:

adb shell service call bluetooth_manager 8

查看更多
做个烂人
4楼-- · 2019-01-18 16:16

To enable:

adb shell service call bluetooth_manager 6

To disable:

adb shell service call bluetooth_manager 9

Tested and worked on a Samsung Galaxy S7.

查看更多
我命由我不由天
5楼-- · 2019-01-18 16:22

On Xiaomi Mi 4i / MIUI 9:

To enable:

adb shell service call bluetooth_manager 8

To disable:

adb shell service call bluetooth_manager 10

This can also run within Andorid like:

service call bluetooth_manager 10

查看更多
登录 后发表回答