Android 应用程序中-设置-蓝牙,若隐藏蓝牙功能

Android 应用程序中-设置-蓝牙,若隐藏蓝牙功能

Android 应用程序中-设置-蓝牙要隐藏蓝牙功能步骤以下: java

1.经过搜索">Bluetooth<"找到相关的定义 android

Settings\res\values\String.xml ui

./res/values/strings.xml:206:    <string name="bluetooth">Bluetooth</string>
./res/values/strings.xml:958:    <string name="bluetooth_quick_toggle_title">Bluetooth</string>
./res/values/strings.xml:962:    <string name="bluetooth_settings">Bluetooth</string>
./res/values/strings.xml:964:    <string name="bluetooth_settings_title">Bluetooth</string>
./res/values/strings.xml:2940:    <string name="power_bluetooth">Bluetooth</string> spa

2.经过bluetooth_settings定义名字找到相关的xml文件 xml

Settings\res\xml\settings_headers.xml rem

<!-- Bluetooth -->
    <header
        android:id="@+id/bluetooth_settings"
        android:fragment="com.android.settings.bluetooth.BluetoothSettings"
        android:title="@string/bluetooth_settings_title"
        android:icon="@drawable/ic_settings_bluetooth2" /> get

3.经过ID,@+id/bluetooth_settings(R.id.bluetooth_settings)找到相关的Java文件 string

Settings\src\com\android\settings\Settings.java
it

private void updateHeaderList(List<Header> target) {//更新Header列表

    if (id == R.id.bluetooth_settings) {
                // Remove Bluetooth Settings if Bluetooth service is not available.
                if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
                    target.remove(header);
                } date

改成:当为真的时候都去移除蓝色选项

    if (id == R.id.bluetooth_settings) {
                // Remove Bluetooth Settings if Bluetooth service is not available.
                if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
                    target.remove(header);
                }

相关文章
相关标签/搜索