返回
顶部

修改密码

Android 检测是否连接蓝牙耳机

+1

-1

收藏

+1

-1

点赞0

评论0

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…
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);
    	}
    }

 

扫一扫在手机打开

评论
已有0条评论
0/150
提交
热门评论
相关推荐
Android蓝牙开发
  • 近场通信
  • 2022-05-20 18:30
  • 5 0 0
+1
android 蓝牙分析
  • 近场通信
  • 2022-05-20 18:30
  • 10 0 0
+1
android4.0蓝牙使能的详细解析
  • 近场通信
  • 2022-05-20 18:30
  • 2 0 0
+1
Android 蓝牙API 之 BluetoothAdapter 类
  • 近场通信
  • 2022-05-20 18:30
  • 1 0 0
+1
android蓝牙源码分析
  • 近场通信
  • 2022-05-20 18:30
  • 5 0 0
+1
今日要闻
换一批
热点排行