version:MTK 3.6

fix:
update:GPS定位成功后关闭
This commit is contained in:
2022-07-29 18:27:49 +08:00
parent 275b7693fc
commit a8c0e5b9bc
2 changed files with 7 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package com.aoleyun.sn.manager;
import android.annotation.SuppressLint;
import android.content.Context;
import android.provider.Settings;
import android.util.Log;
import com.aoleyun.sn.utils.SPUtils;
@@ -41,6 +42,7 @@ public class MapManager {
}
public void initMap() {
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
mLocationClient = new LocationClient(mContext);
mLocationClient.setLocOption(getDefaultLocationClientOption());
mLocationClient.registerLocationListener(mListener);
@@ -49,6 +51,7 @@ public class MapManager {
}
public LocationClient getLocationClient() {
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
if (mLocationClient == null) {
initMap();
}
@@ -123,6 +126,8 @@ public class MapManager {
}
Log.e(TAG, "MapAddress: " + (String) SPUtils.get(mContext, "MapAddress", "-"));
Log.e(TAG, "MapError: " + (String) SPUtils.get(mContext, "MapError", "-"));
// Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-network");
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-gps");
}
@Override