当前位置:操作系统 > 安卓/Android >>

Android 检测是否连接蓝牙耳机

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

 

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,