监听Bluetooth
监听bluetooth的intent可以获得bluetooth相应的状态。
监听的action有:
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
<action android:name="android.bluetooth.adapter.action.SCAN_MODE_CHANGED" />
<action android:name="android.bluetooth.adapter.action.DISCOVERY_STARTED" />
<action android:name="android.bluetooth.adapter.action.DISCOVERY_FINISHED" />
<action android:name="android.bluetooth.adapter.action.LOCAL_NAME_CHANGED" />
<action android:name="android.bluetooth.device.action.FOUND" />
<action android:name="android.bluetooth.device.action.DISAPPEARED" />
<action android:name="android.bluetooth.device.action.CLASS_CHANGED" />
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.device.action.NAME_CHANGED" />
<action android:name="android.bluetooth.device.action.BOND_STATE_CHANGED" />
<action android:name="android.bluetooth.device.action.NAME_FAILED" />
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<action android:name="android.bluetooth.device.action.PAIRING_CANCEL" />
<action android:name="android.bluetooth.device.action.UUID" />
<action android:name="android.bluetooth.headset.action.STATE_CHANGED" />
<action android:name="android.bluetooth.headset.action.AUDIO_STATE_CHANGED" />
<action android:name="android.bluetooth.a2dp.action.SINK_STATE_CHANGED" />
<action android:name="android.bluetooth.devicepicker.action.LAUNCH" />
<action android:name="android.bluetooth.devicepicker.action.DEVICE_SELECTED" />
可以通过Bundle extra = intent.getExra()获得相应intent数据,例如:
Bundle bundle = intent.getExtras();
if (bundle == null) return;
for (String extra : bundle.keySet()) {
Log.d(TAG, "\t " + extra + " = "+ bundle.get(extra));
}
可以得到相应的键值对。
更多相关文章
- Android拦截、监听系统返回键事件
- Android学习笔记——Android生命周期
- 安卓调用键盘回车键做保存或调用搜索键执行操作
- 【Android(安卓)进阶】Android(安卓)Home 键监听
- Android监听手机软键盘的弹起和关闭
- Android之监听手机软键盘弹起与关闭
- Android—Android中监听EditText文本输入,实现修改用户名,清除密码
- Mono登录界面记住密码的控件
- android实现软件指导页