IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
VrHelp.getContext().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "registerBtConnect action : " + intent.getAction());
switch (intent.getAction()){
case BluetoothDevice.ACTION_ACL_CONNECTED:
isConnectBtDevices = true;
Log.d(TAG, "notify TXZ bt connect :" + VrBtManager.getInstance().notifyBtConnectState(true));
break;
case BluetoothDevice.ACTION_ACL_DISCONNECTED:
isConnectBtDevices = false;
Log.d(TAG, "notify TXZ bt disconnect :" + VrBtManager.getInstance().notifyBtConnectState(false));
break;
default:
break;
}
}
},intentFilter);
android监听蓝牙连接状态
猜你喜欢
转载自blog.csdn.net/qq_42447739/article/details/128777001
今日推荐
周排行