700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > android判断是否是蓝牙耳机 Android 检测是否连接蓝牙耳机

android判断是否是蓝牙耳机 Android 检测是否连接蓝牙耳机

时间:2022-03-20 10:08:27

相关推荐

android判断是否是蓝牙耳机 Android 检测是否连接蓝牙耳机

前言 欢迎大家我分享和推荐好用的代码段~~声明 欢迎转载,但请保留文章原始出处: CSDN:

雨季o莫忧离:/luckkof

正文

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

private void handleHeadsetStateChange()

{

Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG);

if(BluetoothProfile.STATE_CONNECTED == adapter.getProfileConnectionState(BluetoothProfile.HEADSET))

{

intent.putExtra("state", 1);

intent.putExtra("microphone", 1);

mContext.sendBroadcast(intent);

}

else if(BluetoothProfile.STATE_DISCONNECTED == adapter.getProfileConnectionState(BluetoothProfile.HEADSET))

{

intent.putExtra("state", -1);

mContext.sendBroadcast(intent);

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。