欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Android 打开蓝牙状态栏显示蓝牙图标

程序员文章站 2022-06-22 09:53:55
系统默认是蓝牙链接后才在状态栏显示蓝牙图标现在修改为打开蓝牙就在状态栏显示蓝牙图标frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java private final void updateBluetooth() { int iconId = R.drawable.stat_sys_data_bluetooth_......

系统默认是蓝牙链接后才在状态栏显示蓝牙图标

现在修改为打开蓝牙就在状态栏显示蓝牙图标

 

frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java 

 

     private final void updateBluetooth() {
         int iconId = R.drawable.stat_sys_data_bluetooth_connected;
         String contentDescription =
                 mResources.getString(R.string.accessibility_quick_settings_bluetooth_on);
         boolean bluetoothVisible = false;
         if (mBluetooth != null) {
+            if(mBluetooth.isBluetoothEnabled()) {
+                bluetoothVisible = mBluetooth.isBluetoothEnabled();
+            }
             if (mBluetooth.isBluetoothConnected()
                     && (mBluetooth.isBluetoothAudioActive()
                     || !mBluetooth.isBluetoothAudioProfileOnly())) {
                 contentDescription = mResources.getString(
                         R.string.accessibility_bluetooth_connected);
                 bluetoothVisible = mBluetooth.isBluetoothEnabled();
             }
         }
 
         mIconController.setIcon(mSlotBluetooth, iconId, contentDescription);
         mIconController.setIconVisibility(mSlotBluetooth, bluetoothVisible);
     }

 

本文地址:https://blog.csdn.net/hmily0917/article/details/110525365

相关标签: Android 状态栏