Android 12.0 开启蓝牙状态栏即显示蓝牙图标

编程入门 行业动态 更新时间:2024-10-27 06:34:06

Android 12.0 开启<a href=https://www.elefans.com/category/jswz/34/1768306.html style=蓝牙状态栏即显示蓝牙图标"/>

Android 12.0 开启蓝牙状态栏即显示蓝牙图标

Android 12.0 开启蓝牙状态栏即显示蓝牙图标

最近收到客户反馈想要在开启蓝牙时状态栏就能显示出蓝牙图标,我们系统默认是蓝牙连接上设备后状态栏才显示出蓝牙图标,具体修改参照如下:

/vendor/mediatek/proprietary/packages/apps/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()) {
+                contentDescription = mResources.getString(R.string.accessibility_quick_settings_bluetooth_on);
+                bluetoothVisible = mBluetooth.isBluetoothEnabled();
+                iconId = R.drawable.ic_qs_bluetooth_on;
+            }if (mBluetooth.isBluetoothConnected()&& (mBluetooth.isBluetoothAudioActive()|| !mBluetooth.isBluetoothAudioProfileOnly())) {
+                iconId = R.drawable.stat_sys_data_bluetooth_connected;contentDescription = mResources.getString(R.string.accessibility_bluetooth_connected);bluetoothVisible = mBluetooth.isBluetoothEnabled();}}

重新编译验证,修改生效,开启蓝牙时状态栏即显示蓝牙图标

更多推荐

Android 12.0 开启蓝牙状态栏即显示蓝牙图标

本文发布于:2023-11-15 17:37:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1603530.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:蓝牙   图标   状态栏   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!