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

當前位置: 首頁 > news >正文

什么做網站/學生網頁制作成品

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

#Android9 查看連接多個藍牙耳機查看使用中的藍牙耳機

文章目錄

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

Android 9.0之后,支持一臺手機可以同時連接多個藍牙設備。

但是判斷那個藍牙設備是使用中,需要經過一些復雜判斷才知道!

一、主要api:

 boolean a2dpPlaying = BluetoothA2dp.isA2dpPlaying(BluetoothDevice);

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

BluetoothA2dp 獲取需要連接服務,BluetoothDevice 遍歷所有藍牙即可。

二、BluetoothA2dp 對象的獲取

BluetoothA2dp mA2dp;public 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);Collection<CachedBluetoothDevice> 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);Collection<CachedBluetoothDevice> 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();

四、其他:

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

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

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

相關文章:

  • 福建建筑人才服務中心檔案/熱狗seo顧問
  • 做網站困難嗎/優秀網站設計欣賞
  • 做貨到付款的購物網站/seo的中文含義是什么
  • 網站后臺是怎樣制作/經典軟文案例100例簡短
  • 2021年有沒有人給個網站/全網營銷系統
  • 長江設計公司/網絡優化報告
  • 萬網網站備案多久/免費優化網站
  • 上海網站排名優化公司/谷歌seo快速排名軟件首頁
  • 網站建設開發平臺/網絡服務器的作用
  • 做平面什么網站好用/百度禁止seo推廣
  • 中國平面設計網站/廣告營銷案例分析
  • 網站建設橙子/百度教育app
  • 蘇省住房和城鄉建設廳網站首頁/百度應用市場app下載安裝
  • 做網站需要源碼/河南做網站優化
  • 主站蜘蛛池模板: 日韩a无v码在线播放| 人妻无码久久久久久久久久久 | 欧美成aⅴ人高清免费| 亚洲人成电影综合网站色www| 亚洲熟妇中文字幕日产无码| 天堂av男人在线播放| 18禁免费无码无遮挡不卡网站| 性饥渴少妇av无码毛片| 亚洲中文字幕av每天更新| 在线视频精品中文无码| 欧美性狂猛bbbbbbxxxxxx精品| 岛国精品一区免费视频在线观看| 99久久婷婷国产综合精品| 亚洲国产成人五月综合网| 色综合久久无码中文字幕app| 国产成人综合久久精品推下载| 久久久久99精品成人片试看| 日韩中文无码有码免费视频| 亚洲国产精品成人久久久| 热99re久久国免费超精品首页| 尤物tv国产精品看片在线| 女人18毛片水真多免费视频| 精品久久久噜噜噜久久久| 亚洲精品国产欧美一二区| 上司揉捏人妻丰满双乳电影| 国产xxxx做受性欧美88| 国产精品毛片a∨一区二区三区| 拍摄av现场失控高潮数次| 久久www免费人成—看片| 日本又黄又爽又色又刺激的视频| 精品极品三大极久久久久| 国产人妻人伦精品1国产| 国产高清精品福利私拍国产写真| 韩国午夜福利片在线观看 | 五月开心婷婷六月丁香婷| 久热这里只有精品12| 亚洲午夜久久久久久久久久| 国产精品99久久99久久久不卡| 中文字幕v亚洲日本在线电影| 午夜精品一区二区三区免费视频| 青青草在久久免费久久免费 |