更改GPS minTime当电池电量不足或连接到电源时,请求位置更新

更改GPS minTime当电池电量不足或连接到电源时,请求位置更新,gps,location,locationmanager,locationlistener,Gps,Location,Locationmanager,Locationlistener,我正在设置LocationManager设置,如下所示: long MIN_TIME_BETWEEN_GPS_UPDATES = 0; // in min! long MAX_TIME_BETWEEN_GPS_UPDATES = 1; //in min! int DISTANCE_BETWEEN_UPDATES = 0; mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mlocListene

我正在设置LocationManager设置,如下所示:

long MIN_TIME_BETWEEN_GPS_UPDATES = 0; // in min! 
long MAX_TIME_BETWEEN_GPS_UPDATES = 1; //in min!
int DISTANCE_BETWEEN_UPDATES = 0;
mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,(MAX_TIME_BETWEEN_GPS_UPDATES * 60 * 1000), DISTANCE_BETWEEN_UPDATES, mlocListener);
现在,当连接充电器时,我想减少最小时间

mlocManager.removeUpdates(mlocListener);
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,(MIN_TIME_BETWEEN_GPS_UPDATES * 60 * 1000), DISTANCE_BETWEEN_UPDATES, mlocListener);
当我断开充电器时,我想增加minTime,这样gps每分钟都会给我一次更新

mlocManager.removeUpdates(mlocListener);
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,(MAX_TIME_BETWEEN_GPS_UPDATES * 60 * 1000), DISTANCE_BETWEEN_UPDATES, mlocListener);
因此,每次我想要更改minTime时,我都会调用.removeUpdate函数,然后调用 .requestLocationUpdates函数再次更改设置

然而,这对我不起作用。如果我想第二次更改设置,我需要打开gps并再次打开

是否有人在更改locationManager的设置(minTime)以更改位置更新之间的间隔时遇到问题