简体   繁体   English

如何在Android中实现LocationManager的requestLocationUpdates?

[英]How does really work the requestLocationUpdates of LocationManager in Android?

Working with the Location Manager in Android, nce you first call the requestLocationUpdates, the value you pass it to select the refresh time can be changed? 使用Android中的位置管理器,你首先调用requestLocationUpdates,你传递它的值来选择刷新时间可以改变吗?

Let me explain. 让我解释。 Here we have what I'm doing (and works perfect): 在这里,我们有我正在做的事情(并且完美无缺):

(...)
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPSrefresh, GPSminDistance, locationListener);

(...)
public void onLocationChanged(Location location) {
// Do what you want to do 
}

If, after some time, I change the value of GPSrefresh , Is it going to affect to the locationUpdates? 如果在一段时间后,我改变了GPSrefresh的值,是否会影响到locationUpdates? Is it always checking the value of GPSrefresh or it just did it the first time it was called? 它总是检查GPSrefresh的值,还是第一次调用它时才这样做?

Thank you very much. 非常感谢你。

you are passing values to a method requestLocationUpdates of LocationManager calss and then updateing that value..so it will not affect the previous method call.. 您将值传递给LocationManager calss的方法requestLocationUpdates ,然后更新该值..因此它不会影响以前的方法调用..

Like, String tmp="Mango"; 比如, String tmp =“Mango”; Fruits.add(tmp); Fruits.add(TMP); tmp="Apple"; TMP = “苹果”;

in above only Mango will be added..to add Apple you will have to call Fruits.add(tmp) again , 以上仅芒果将added..to添加苹果将不得不再次调用Fruits.add(TMP),

Same way.. IF you cange value of GPSRefresh you will need to call the method requestLocationUpdates again with the new updated parameters. 同样的方法.. 如果您能够获得GPSRefresh的值,您将需要使用新的更新参数再次 调用方法requestLocationUpdates

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM