android怎样监听蓝牙状态变化的消息啊。类似拦截短信一样
答案:2 悬赏:0
解决时间 2021-01-21 04:41
- 提问者网友:謫仙
- 2021-01-20 11:47
android怎样监听蓝牙状态变化的消息啊。类似拦截短信一样
最佳答案
- 二级知识专家网友:低血压的长颈鹿
- 2021-01-20 12:55
刚看了sdk,发现有个:android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED
这是个广播
Broadcast Action: The state of the local Bluetooth adapter has been changed.
For example, Bluetooth has been turned on or off.
可以监听到蓝牙打开和关闭。想要更多的自己去查查吧
这是个广播
Broadcast Action: The state of the local Bluetooth adapter has been changed.
For example, Bluetooth has been turned on or off.
可以监听到蓝牙打开和关闭。想要更多的自己去查查吧
全部回答
- 1楼网友:逃夭
- 2021-01-20 14:18
SDK 2.0以后的在xml中注册Receiver添加下面需要用到的action
android.bluetooth.a2dp.action.SINK_STATE_CHANGED
android.bluetooth.adapter.action.DISCOVERY_FINISHED
android.bluetooth.adapter.action.DISCOVERY_STARTED
android.bluetooth.adapter.action.LOCAL_NAME_CHANGED
android.bluetooth.adapter.action.SCAN_MODE_CHANGED
android.bluetooth.adapter.action.STATE_CHANGED
android.bluetooth.device.action.ACL_CONNECTED
android.bluetooth.device.action.ACL_DISCONNECTED
android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED
android.bluetooth.device.action.BOND_STATE_CHANGED
android.bluetooth.device.action.CLASS_CHANGED
android.bluetooth.device.action.FOUND
android.bluetooth.device.action.NAME_CHANGED
android.bluetooth.devicepicker.action.DEVICE_SELECTED
android.bluetooth.devicepicker.action.LAUNCH
android.bluetooth.headset.action.AUDIO_STATE_CHANGED
android.bluetooth.headset.action.STATE_CHANGED
android.bluetooth.a2dp.action.SINK_STATE_CHANGED
android.bluetooth.adapter.action.DISCOVERY_FINISHED
android.bluetooth.adapter.action.DISCOVERY_STARTED
android.bluetooth.adapter.action.LOCAL_NAME_CHANGED
android.bluetooth.adapter.action.SCAN_MODE_CHANGED
android.bluetooth.adapter.action.STATE_CHANGED
android.bluetooth.device.action.ACL_CONNECTED
android.bluetooth.device.action.ACL_DISCONNECTED
android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED
android.bluetooth.device.action.BOND_STATE_CHANGED
android.bluetooth.device.action.CLASS_CHANGED
android.bluetooth.device.action.FOUND
android.bluetooth.device.action.NAME_CHANGED
android.bluetooth.devicepicker.action.DEVICE_SELECTED
android.bluetooth.devicepicker.action.LAUNCH
android.bluetooth.headset.action.AUDIO_STATE_CHANGED
android.bluetooth.headset.action.STATE_CHANGED
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯