展会信息港展会大全

Android 检测是否连接蓝牙耳机
来源:互联网   发布日期:2015-09-28 16:02:16   浏览:1812次  

导读:private void handleHeadsetStateChange() { Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG); if(BluetoothProfile.STATE_CONNECTED == adapter.getProfileConnectionState(BluetoothProfile.HEADSET)) { intent.putExtra(state, 1); intent.putEx...

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开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港