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

Android 6.0 默认关闭定位和GPS,开启后默认选省电

程序员文章站 2022-05-25 21:10:47
默认关闭定位和GPS 修改位置 frameworks/base/packages/SettingsProvider/res/values/defaults.xml network,gps 修改为 默认省电 修改位置 com/android/settings/location/LocationSett ......

默认关闭定位和gps 修改位置

frameworks/base/packages/settingsprovider/res/values/defaults.xml

<string name="def_location_providers_allowed" translatable="false">network,gps</string>
修改为
<string name="def_location_providers_allowed" translatable="false"></string>

默认省电 修改位置

com/android/settings/location/locationsettings.java

public class locationsettings extends locationsettingsbase
 @override
 public void onswitchchanged(switch switchview, boolean ischecked) {
     if (ischecked) {
     //setlocationmode(android.provider.settings.secure.location_mode_high_accuracy);   
         setlocationmode(android.provider.settings.secure.location_mode_battery_saving);
     } else {
         setlocationmode(android.provider.settings.secure.location_mode_off);
     }