gpt4 book ai didi

android - requestLocationUpdates 中的更新间隔

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:55:49 40 4
gpt4 key购买 nike

如何更新时间和距离间隔,或者以不同的间隔再次调用 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 );,然后使用您的新间隔重新注册更新。

关于android - requestLocationUpdates 中的更新间隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6340688/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com