Settings中删除一些默认的选项
os:android7.1
需求:设置有很多默认选项,有些定制的项目不需要这些多余的选项(比如:流量使用情况、电池、位置信息等),需要删除掉这些选项菜单。
比如去掉wifi这一选项菜单,修改如下:
packages/apps/Settings/src/com/android/settings/SettingsActivity.java
--- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -1059,8 +1059,10 @@ public class SettingsActivity extends SettingsDrawerActivity final boolean isAdmin = um.isAdminUser(); String packageName = getPackageName(); - setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()), - pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm); + // setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()), + // pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm); + + setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()),false, isAdmin, pm); setTileEnabled(new ComponentName(packageName, Settings.BluetoothSettingsActivity.class.getName()),
删除其他菜单也是一样,其实就是把就应选项菜单的setTileEnabled的第三个参数改为false即可。