我正在设置locationManagers设置如下:
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);
现在,当连接充电器时,我想减少minTime
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)以更改位置更新之间的间隔时遇到问题?