当前位置: 首页 > news >正文 合肥网站推广单机传奇手游无需联网 news 2025/10/26 13:35:32 合肥网站推广,单机传奇手游无需联网,母婴网站开发,珠海中企网站建设公司#Android9 查看连接多个蓝牙耳机查看使用中的蓝牙耳机 文章目录 一、主要api#xff1a;二、BluetoothA2dp 对象的获取三、获取 BluetoothDevice 对象#xff0c;四、其他#xff1a; Android 9.0之后#xff0c;支持一台手机可以同时连接多个蓝牙设备。 但是判断那个蓝牙…#Android9 查看连接多个蓝牙耳机查看使用中的蓝牙耳机 文章目录 一、主要api二、BluetoothA2dp 对象的获取三、获取 BluetoothDevice 对象四、其他 Android 9.0之后支持一台手机可以同时连接多个蓝牙设备。 但是判断那个蓝牙设备是使用中需要经过一些复杂判断才知道 一、主要api boolean a2dpPlaying BluetoothA2dp.isA2dpPlaying(BluetoothDevice); 看起来不难但是 BluetoothA2dp 和 BluetoothDevice 如何获取到 BluetoothA2dp 获取需要连接服务BluetoothDevice 遍历所有蓝牙即可。 二、BluetoothA2dp 对象的获取 BluetoothA2dp mA2dppublic void initA2dpAdapter() {BluetoothAdapter mBluetoothAdapter BluetoothAdapter.getDefaultAdapter();if (mBluetoothAdapter.isEnabled()) { //判断蓝牙是否开启//获取A2DP代理对象if (mA2dp null) { //不能重复连接服务否则会报错mBluetoothAdapter.getProfileProxy(getContext(), mBluetoothProfileListener, BluetoothProfile.A2DP);}} else {LogUtil.error(getA2dpAdapter error. bluetooth is not Enabled);}}//getProfileProxy并不会直接返回A2DP代理对象而是通过mListener中回调获取。private BluetoothProfile.ServiceListener mBluetoothProfileListener new BluetoothProfile.ServiceListener() {Overridepublic void onServiceDisconnected(int profile) {if (profile BluetoothProfile.A2DP) {LogUtil.error(A2dp onServiceDisconnected );mA2dp null;}}// getProfileProxy 到 连接成功一般需要几十毫秒Overridepublic void onServiceConnected(int profile, BluetoothProfile proxy) {if (profile BluetoothProfile.A2DP) {LogUtil.error(A2dp onServiceConnected );mA2dp (BluetoothA2dp) proxy; //转换 这个就是 BluetoothA2dp 对象//不显示蓝牙界面连接耳机会出现多个连接状态的蓝牙耳机断开非使用中的蓝牙耳机judgeIsConnectManyBluetooth();}}};三、获取 BluetoothDevice 对象 //判断所有的耳机设备是否存在多个连接状态的private boolean isConnectManyBluetooth() {//未从已连接设备列表中找到断开的api从所有的设备列表中进行判断连接状态后断开LocalBluetoothManager mBluetoothManager LocalBluetoothManager.getInstance(context, mOnInitCallback);CollectionCachedBluetoothDevice cachedDevices mBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();LogUtil.debug(cachedDevices size cachedDevices.size());//更新蓝牙列表UIint connectDevices 0;for (CachedBluetoothDevice cachedDevice : cachedDevices) {String name cachedDevice.getDevice().getName();if (cachedDevice.isConnected()) {LogUtil.debug(cachedDevices name name);connectDevices;}if (connectDevices 1) {return true;}}return false;}//判断是否多个蓝牙连接状态如果是就断开非使用中的蓝牙private void judgeIsConnectManyBluetooth() {if (isConnectManyBluetooth()) {//获取当前使用中的蓝牙耳机对象断开其他耳机对象LocalBluetoothManager mBluetoothManager LocalBluetoothManager.getInstance(context, mOnInitCallback);CollectionCachedBluetoothDevice cachedDevices mBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();LogUtil.debug(cachedDevices size cachedDevices.size());//更新蓝牙列表UIfor (CachedBluetoothDevice cachedDevice : cachedDevices) {String name cachedDevice.getDevice().getName();if (mA2dp ! null cachedDevice.getDevice() ! null) {boolean a2dpPlaying mA2dp.isA2dpPlaying(cachedDevice.getDevice()); //判断蓝牙是否使用中if (a2dpPlaying) {LogUtil.debug(cachedDevices a2dpPlaying name name);disconnectOtherExceptOne(name, cachedDevice.getDevice().getBluetoothClass().getMajorDeviceClass());}}}}} LocalBluetoothManager 这个类是SettingLib 里面的类如果不是系统源码或者系统应用是调用不到的可以用反射 上面是实际项目中的一段代码其实具体获取 BluetoothDevice api只有个两句 CachedBluetoothDevice cachedDevice;//单个蓝牙对象 BluetoothDevice bluetoothDevice cachedDevice.getDevice(); 四、其他 //已连接/绑定设备列表SetBluetoothDevice bondedDevices mBluetoothManager.getBluetoothAdapter().getBondedDevices(); BluetoothDevice 对象没有啥连接和断开操作的方法只有一下配置信息。 文章转载自: http://www.morning.nkjnr.cn.gov.cn.nkjnr.cn http://www.morning.yszrk.cn.gov.cn.yszrk.cn http://www.morning.txgjx.cn.gov.cn.txgjx.cn http://www.morning.svrud.cn.gov.cn.svrud.cn http://www.morning.wnhml.cn.gov.cn.wnhml.cn http://www.morning.sflnx.cn.gov.cn.sflnx.cn http://www.morning.mnsmb.cn.gov.cn.mnsmb.cn http://www.morning.jyjqh.cn.gov.cn.jyjqh.cn http://www.morning.tztgq.cn.gov.cn.tztgq.cn http://www.morning.jjhng.cn.gov.cn.jjhng.cn http://www.morning.smpmn.cn.gov.cn.smpmn.cn http://www.morning.chmcq.cn.gov.cn.chmcq.cn http://www.morning.cyysq.cn.gov.cn.cyysq.cn http://www.morning.tsqrc.cn.gov.cn.tsqrc.cn http://www.morning.hhmfp.cn.gov.cn.hhmfp.cn http://www.morning.mfrb.cn.gov.cn.mfrb.cn http://www.morning.lqynj.cn.gov.cn.lqynj.cn http://www.morning.ctrkh.cn.gov.cn.ctrkh.cn http://www.morning.rwbx.cn.gov.cn.rwbx.cn http://www.morning.fqlxg.cn.gov.cn.fqlxg.cn http://www.morning.sbjbs.cn.gov.cn.sbjbs.cn http://www.morning.zgdnz.cn.gov.cn.zgdnz.cn http://www.morning.bbxbh.cn.gov.cn.bbxbh.cn http://www.morning.sqskm.cn.gov.cn.sqskm.cn http://www.morning.kzcfr.cn.gov.cn.kzcfr.cn http://www.morning.zqsnj.cn.gov.cn.zqsnj.cn http://www.morning.mxptg.cn.gov.cn.mxptg.cn http://www.morning.fllfc.cn.gov.cn.fllfc.cn http://www.morning.sfqtf.cn.gov.cn.sfqtf.cn http://www.morning.ztcxx.com.gov.cn.ztcxx.com http://www.morning.nmqdk.cn.gov.cn.nmqdk.cn http://www.morning.ccffs.cn.gov.cn.ccffs.cn http://www.morning.ymfzd.cn.gov.cn.ymfzd.cn http://www.morning.qlhwy.cn.gov.cn.qlhwy.cn http://www.morning.sjwzz.cn.gov.cn.sjwzz.cn http://www.morning.mlmwl.cn.gov.cn.mlmwl.cn http://www.morning.zwdrz.cn.gov.cn.zwdrz.cn http://www.morning.yccnj.cn.gov.cn.yccnj.cn http://www.morning.rrcrs.cn.gov.cn.rrcrs.cn http://www.morning.ydnxm.cn.gov.cn.ydnxm.cn http://www.morning.jfymz.cn.gov.cn.jfymz.cn http://www.morning.wcqxj.cn.gov.cn.wcqxj.cn http://www.morning.rknsp.cn.gov.cn.rknsp.cn http://www.morning.nwtmy.cn.gov.cn.nwtmy.cn http://www.morning.lzqdd.cn.gov.cn.lzqdd.cn http://www.morning.crrmg.cn.gov.cn.crrmg.cn http://www.morning.nqypf.cn.gov.cn.nqypf.cn http://www.morning.nxwk.cn.gov.cn.nxwk.cn http://www.morning.c7629.cn.gov.cn.c7629.cn http://www.morning.fwnyz.cn.gov.cn.fwnyz.cn http://www.morning.jzsgn.cn.gov.cn.jzsgn.cn http://www.morning.dpgdj.cn.gov.cn.dpgdj.cn http://www.morning.wkxsy.cn.gov.cn.wkxsy.cn http://www.morning.xlmpj.cn.gov.cn.xlmpj.cn http://www.morning.mxlwl.cn.gov.cn.mxlwl.cn http://www.morning.rbqlw.cn.gov.cn.rbqlw.cn http://www.morning.ghcfx.cn.gov.cn.ghcfx.cn http://www.morning.tcpnp.cn.gov.cn.tcpnp.cn http://www.morning.wphzr.cn.gov.cn.wphzr.cn http://www.morning.sjjtz.cn.gov.cn.sjjtz.cn http://www.morning.sldrd.cn.gov.cn.sldrd.cn http://www.morning.fkwp.cn.gov.cn.fkwp.cn http://www.morning.kzcfr.cn.gov.cn.kzcfr.cn http://www.morning.fkfyn.cn.gov.cn.fkfyn.cn http://www.morning.chmkt.cn.gov.cn.chmkt.cn http://www.morning.nccqs.cn.gov.cn.nccqs.cn http://www.morning.pqsys.cn.gov.cn.pqsys.cn http://www.morning.qtryb.cn.gov.cn.qtryb.cn http://www.morning.gbljq.cn.gov.cn.gbljq.cn http://www.morning.hmxb.cn.gov.cn.hmxb.cn http://www.morning.wjzzh.cn.gov.cn.wjzzh.cn http://www.morning.drnfc.cn.gov.cn.drnfc.cn http://www.morning.ryxbz.cn.gov.cn.ryxbz.cn http://www.morning.rqwwm.cn.gov.cn.rqwwm.cn http://www.morning.plxhq.cn.gov.cn.plxhq.cn http://www.morning.fksdd.cn.gov.cn.fksdd.cn http://www.morning.dsxgc.cn.gov.cn.dsxgc.cn http://www.morning.ftmp.cn.gov.cn.ftmp.cn http://www.morning.qnksk.cn.gov.cn.qnksk.cn http://www.morning.jbhhj.cn.gov.cn.jbhhj.cn 查看全文 http://www.tj-hxxt.cn/news/251122.html 相关文章: 做推广网站公司做一个网站需要多大的空间 阿里云有了域名 网站建设免费的小网站 良匠网站建设行业网站开发费用 写作网站招聘教务处网站建设 网站开发的总结小程序 深圳公司 蒲城网站建设wzjseo可以自己做网站做宣传吗 网站里添加图片超链接怎么做9元建站节 游戏网站设计风格有哪些上海魔力网站建设公司 农业网站建设公司中国有哪些企业网站 psd模板免费下载网站网站建设网络营销 网站设置为应用程序深圳营销网站设计 企业网站建立哪怎么在app中嵌入h5页面 广东建网站公司校园网站建设教程视频 企业网站的建设目标有哪几种优化关键词快速排名 怎么在百度做原创视频网站北京定制网站开发公司 广东网站建设公司报价网站用户体验是什么 高端网站制作 上海app如何制作(怎么自己做app) 佛山网站设计哪里好wordpress更新配置 新手入门网站建设怎么做制作网站的教程 安徽合肥建设厅网站做废钢推广网站 已有网站可以做服务器吗公司网站后台更新 网站换了域名怎么查com域名注册量 哪些网站可以做设计韩国美食做视频网站有哪些 全网营销型网站网站备案客户资料 企业策划咨询公司seo优化软件 网站建设的费用结构成都私人做网站 网站建设需要了解什么主流软件开发平台 成都建设网站那个好网站文章更新时间 有什么网站可以做宣传有哪些公司建设网站 大团企业网站制作神马搜索推广