Anroid R上开启蓝牙后,状态栏上并不会直接显示蓝牙图标的。只有在蓝牙连接传输的时候才会有蓝牙图标显示。
原生实现是在PhoneStatusBarPolicy.java中:
private final void updateBluetooth() {
......
if (mBluetooth != null) {
if (mBluetooth.isBluetoothConnected()
&& (mBluetooth.isBluetoothAudioActive()
|| !mBluetooth.isBluetoothAudioProfileOnly())) {
contentDescription = mResources.getString(
R.string.accessibility_bluetooth_connected);
bluetoothVisible = mBluetooth.isBluetoothEnabled();
}
}
......
}
复制代码
解决方案:
将bluetoothVisible赋值的条件设置为bluetooth enable。
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();
+ //bluetoothVisible = mBluetooth.isBluetoothEnabled();
}
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END