亚洲精品无码久久不卡丨熟女少妇人妻中文字幕丨午夜内射高潮视频丨视频区国产亚洲.欧美丨少妇三级全黄

當(dāng)前位置: 首頁 > news >正文

什么做網(wǎng)站/學(xué)生網(wǎng)頁制作成品

什么做網(wǎng)站,學(xué)生網(wǎng)頁制作成品,wordpress 頂端加代碼,小挑可以做網(wǎng)站嗎#Android9 查看連接多個藍(lán)牙耳機(jī)查看使用中的藍(lán)牙耳機(jī) 文章目錄 一、主要api:二、BluetoothA2dp 對象的獲取三、獲取 BluetoothDevice 對象,四、其他: Android 9.0之后,支持一臺手機(jī)可以同時連接多個藍(lán)牙設(shè)備。 但是判斷那個藍(lán)牙…

#Android9 查看連接多個藍(lán)牙耳機(jī)查看使用中的藍(lán)牙耳機(jī)

文章目錄

    • 一、主要api:
    • 二、BluetoothA2dp 對象的獲取
    • 三、獲取 BluetoothDevice 對象,
    • 四、其他:

Android 9.0之后,支持一臺手機(jī)可以同時連接多個藍(lán)牙設(shè)備。

但是判斷那個藍(lán)牙設(shè)備是使用中,需要經(jīng)過一些復(fù)雜判斷才知道!

一、主要api:

 boolean a2dpPlaying = BluetoothA2dp.isA2dpPlaying(BluetoothDevice);

看起來不難,但是 BluetoothA2dp 和 BluetoothDevice 如何獲取到?

BluetoothA2dp 獲取需要連接服務(wù),BluetoothDevice 遍歷所有藍(lán)牙即可。

二、BluetoothA2dp 對象的獲取

BluetoothA2dp mA2dp;public void initA2dpAdapter() {BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();if (mBluetoothAdapter.isEnabled()) { //判斷藍(lán)牙是否開啟//獲取A2DP代理對象if (mA2dp == null) { //不能重復(fù)連接服務(wù),否則會報錯mBluetoothAdapter.getProfileProxy(getContext(), mBluetoothProfileListener, BluetoothProfile.A2DP);}} else {LogUtil.error("getA2dpAdapter error. bluetooth is not Enabled");}}//getProfileProxy并不會直接返回A2DP代理對象,而是通過mListener中回調(diào)獲取。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; //轉(zhuǎn)換 ,這個就是  BluetoothA2dp 對象//不顯示藍(lán)牙界面連接耳機(jī)會出現(xiàn)多個連接狀態(tài)的藍(lán)牙耳機(jī),斷開非使用中的藍(lán)牙耳機(jī)judgeIsConnectManyBluetooth();}}};

三、獲取 BluetoothDevice 對象,

	//判斷所有的耳機(jī)設(shè)備是否存在多個連接狀態(tài)的private boolean isConnectManyBluetooth() {//未從已連接設(shè)備列表中找到斷開的api,從所有的設(shè)備列表中進(jìn)行判斷連接狀態(tài)后斷開LocalBluetoothManager mBluetoothManager = LocalBluetoothManager.getInstance(context, mOnInitCallback);Collection<CachedBluetoothDevice> cachedDevices = mBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();LogUtil.debug("cachedDevices size = " + cachedDevices.size());//更新藍(lán)牙列表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;}//判斷是否多個藍(lán)牙連接狀態(tài),如果是就斷開非使用中的藍(lán)牙private void judgeIsConnectManyBluetooth() {if (isConnectManyBluetooth()) {//獲取當(dāng)前使用中的藍(lán)牙耳機(jī)對象,斷開其他耳機(jī)對象LocalBluetoothManager mBluetoothManager = LocalBluetoothManager.getInstance(context, mOnInitCallback);Collection<CachedBluetoothDevice> cachedDevices = mBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();LogUtil.debug("cachedDevices size = " + cachedDevices.size());//更新藍(lán)牙列表UIfor (CachedBluetoothDevice cachedDevice : cachedDevices) {String name = cachedDevice.getDevice().getName();if (mA2dp != null && cachedDevice.getDevice() != null) {boolean a2dpPlaying = mA2dp.isA2dpPlaying(cachedDevice.getDevice());  //判斷藍(lán)牙是否使用中!if (a2dpPlaying) {LogUtil.debug("cachedDevices a2dpPlaying name = " + name);disconnectOtherExceptOne(name, cachedDevice.getDevice().getBluetoothClass().getMajorDeviceClass());}}}}}

LocalBluetoothManager 這個類是SettingLib 里面的類,如果不是系統(tǒng)源碼或者系統(tǒng)應(yīng)用是調(diào)用不到的!可以用反射!

上面是實際項目中的一段代碼,其實具體獲取 BluetoothDevice api只有個兩句:

CachedBluetoothDevice cachedDevice;//單個藍(lán)牙對象
BluetoothDevice  bluetoothDevice = cachedDevice.getDevice();

四、其他:

     //已連接/綁定設(shè)備列表Set<BluetoothDevice> bondedDevices = mBluetoothManager.getBluetoothAdapter().getBondedDevices();

BluetoothDevice 對象沒有啥連接和斷開操作的方法!只有一下配置信息。

http://www.jialimach.com/news/20.html

相關(guān)文章:

  • 福建建筑人才服務(wù)中心檔案/熱狗seo顧問
  • 做網(wǎng)站困難嗎/優(yōu)秀網(wǎng)站設(shè)計欣賞
  • 做貨到付款的購物網(wǎng)站/seo的中文含義是什么
  • 網(wǎng)站后臺是怎樣制作/經(jīng)典軟文案例100例簡短
  • 2021年有沒有人給個網(wǎng)站/全網(wǎng)營銷系統(tǒng)
  • 長江設(shè)計公司/網(wǎng)絡(luò)優(yōu)化報告
  • 萬網(wǎng)網(wǎng)站備案多久/免費優(yōu)化網(wǎng)站
  • 上海網(wǎng)站排名優(yōu)化公司/谷歌seo快速排名軟件首頁
  • 網(wǎng)站建設(shè)開發(fā)平臺/網(wǎng)絡(luò)服務(wù)器的作用
  • 做平面什么網(wǎng)站好用/百度禁止seo推廣
  • 中國平面設(shè)計網(wǎng)站/廣告營銷案例分析
  • 網(wǎng)站建設(shè)橙子/百度教育app
  • 蘇省住房和城鄉(xiāng)建設(shè)廳網(wǎng)站首頁/百度應(yīng)用市場app下載安裝
  • 做網(wǎng)站需要源碼/河南做網(wǎng)站優(yōu)化
  • 主站蜘蛛池模板: 精品国产乱码久久久久久下载| 成人av无码国产在线一区| 综合无码成人aⅴ视频免费| 真实国产乱子伦在线视频| 99精品视频在线观看婷婷| 四虎国产精品永久在线| 久久天天躁狠狠躁夜夜不卡| 国产精品美女久久久9999| 日本亚洲欧美综合在线| 少妇人妻偷人精品一区二区| 在线视频国产制服丝袜| 女女女女女裸体处开bbb| 午夜性开放午夜性爽爽| 亚洲综合色88综合天堂| 国产97人人超碰cao蜜芽prom| 久久综合狠狠色综合伊人| 国产白丝护士av在线网站| 亚洲aⅴ综合av国产八av| 国产真人性做爰久久网站| av中文无码韩国亚洲色偷偷| 久久久亚洲欧洲日产av| 乱熟女高潮一区二区在线| 国产成人精品一区二区三区免费 | 七月丁香五月婷婷首页| 国产做爰全免费的视频| 欧美人与禽猛交狂配| 亚洲综合久久成人av| 秋霞av在线露丝片av无码| 国产av精国产传媒| 国产吃奶在线观看| 少妇被爽到高潮在线观看| 爆乳2把你榨干哦ova在线观看| 高清无码视频直接看| 无码成人h免费视频在线观看| 免费看18禁止观看黄网站| 中文字幕肉感巨大的乳专区| 美乳丰满人妻无码视频| ass日本丰满熟妇pics| 仙踪林果冻传媒一区二区| 欧美肥胖老妇bbw| 国产做a爱片久久毛片a片高清|