requestLocationUpdates中的更新间隔

问题描述

| 如何更新时间和距离间隔,或以不同的间隔再次调用requestLocationUpdates? 我的代码:
LocationManager locationManager = (LocationManager) activityObject.getSystemService(Context.LOCATION_SERVICE);

    cll = new CheckinLocationListener();

    LocationProvider gps = locationManager.getProvider(LocationManager.GPS_PROVIDER);

    // GPS

    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,timeDelay,distanceDelay,cll);

    Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
onLocationChanged:
if(location.getSpeed()>=0 && location.getSpeed()<= 3)
            {
                LocationsModel.this.distanceDelay = 25;
                LocationsModel.this.timeDelay = 10000;
            }
            else if(location.getSpeed()>=3 && location.getSpeed()<= 17)
            {
                LocationsModel.this.distanceDelay = 150;
                LocationsModel.this.timeDelay = 60000;
            }
            else if(location.getSpeed()>=17)
            {
                LocationsModel.this.distanceDelay = 300;
                LocationsModel.this.timeDelay = 240000;
            }
我想在下一个度量中使用新间隔。     

解决方法

        您需要先致电
locationManager.removeUpdates( cll );
,然后使用新的时间间隔重新注册更新。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...