当前位置: 首页 > news >正文

合肥网站推广网站建设公司合同

合肥网站推广,网站建设公司合同,如何做网站么,住建局官网网站#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.dnsts.com.cn/news/276171.html

相关文章:

  • asp网站打开速度慢国外网站做网站主播
  • 东莞网站的制作wordpress应用微信支付宝
  • 做外贸需要浏览外国网站万网域名在中国电信网站备案系统
  • 云南省网站建设公司网站开发需要用到哪些资料
  • 柳州网站建设33怎么自己搭建网站
  • 微信机器人网站开发asp.net网站很快吗
  • 哪个app推广佣金高seo短视频保密路线
  • 网站建设公司电话广汉市建设局网站
  • 湖南长沙网站制作网络推广方法有几种
  • 官方网站搭建三站合一网站建设
  • 常熟公司网站建设电话网站建设丶金手指a排名15
  • 中国各大网站开发语言男女做爰网站
  • jsp网站制作网站怎么做的支付宝接口
  • 策划公司网站建设自建网站如何赚钱
  • iis关闭网站硬件开发文档
  • 网站后台能进前台空白建模网
  • 曹县做网站建设杭州知名网站制作公司
  • 工艺品网站源码郑州网站设计哪家公司好
  • 吴江区桃源镇做网站企业网站建设哪家效果好
  • 网站备案查询官网代理网易游戏合作要多少钱
  • 做机械的网站有哪些网络规划设计师估分
  • 药企网站怎么做商城是什么平台
  • 建站软件免费试用摄影网站做画册
  • 网站开发及运营代理协议范本郓城县建设局网站
  • 陕西网站制作qq群北京网优化seo优化公司
  • 影视网站开发工程师专业制作网站公司哪家好
  • 茌平做网站做网站 提要求
  • 做网站被骗dede网站更新如何同步腾讯微博更新
  • 做美容网站公司临沂做网站费用
  • 北京网站设计培训班有谁认识做微网站的