我最近偶然发现了这条消息,我非常肯定这个构造函数在18.0.0之前的版本中没有被弃用,但是我在任何地方都找不到这个构造函数被弃用的信息。我们应该用什么来代替,有没有其他方法来创建一个locationRequest?
locationRequest
xdnvmnnf1#
是的,LocationRequest建构函式已过时。您可以使用它的静态方法LocationRequest.create()来建立位置要求。Kotlin:
LocationRequest.create()
locationRequest = LocationRequest.create().apply { interval = 100 fastestInterval = 50 priority = LocationRequest.PRIORITY_HIGH_ACCURACY maxWaitTime = 100 }
java 语:
locationRequest = LocationRequest.create() .setInterval(100) .setFastestInterval(3000) .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setMaxWaitTime(100);
更新
正如@Shimon所指出的,LocationRequest.PRIORITY_HIGH_ACCURACY现在已弃用,因此请改用Priority.PRIORITY_HIGH_ACCURACY
xhv8bpkk2#
该行现在已弃用:优先级=位置请求。优先级_高_精度替换为优先级=优先级.优先级_高_精度
d7v8vwbk3#
对于任何在Flutter的geolocator 8.0.1中遇到这个错误的人。现在试着编辑FusedLocationClient.java:199。然后等待作者更新发布包起始日期
geolocator 8.0.1
FusedLocationClient.java:199
LocationRequest locationRequest = new LocationRequest();
结束日期
LocationRequest locationRequest = LocationRequest.create();
这是LocationRequest类
LocationRequest
zed5wv104#
更新日期:
常量 PRIORITY_HIGH_ACCURACY 已过时,请改用 Priority.PRIORITY_HIGH_ACCURACY
PRIORITY_HIGH_ACCURACY
Priority.PRIORITY_HIGH_ACCURACY
private fun updateLocationTracking(isTracking: Boolean) { if(isTracking) { if(TrackingUtility.hasLocationPermissions(this)) { val request = LocationRequest.create().apply { interval = LOCATION_UPDATE_INTERVAL fastestInterval = FASTEST_LOCATION_INTERVAL priority = Priority.PRIORITY_HIGH_ACCURACY } }
f0brbegy5#
LocationRequest.create().apply{ ... }现在也不建议使用。请改用LocationRequest.Builder()。例如,如下所示:(locationInterval、locationFastestInterval和locationMaxWaitTime对应于之前使用create()时使用的值)
LocationRequest.create().apply{ ... }
LocationRequest.Builder()
locationInterval
locationFastestInterval
locationMaxWaitTime
create()
locationRequest = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, locationInterval) .setWaitForAccurateLocation(false) .setMinUpdateIntervalMillis(locationFastestInterval) .setMaxUpdateDelayMillis(locationMaxWaitTime) .build()
请在此处阅读更多信息:https://developer.android.com/reference/android/location/LocationRequest.Builder
rggaifut6#
LocationRequest locationRequest = LocationRequest.create() //if you want access of variable .setInterval(100) .setFastestInterval(3000) .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setNumUpdates(1) .setMaxWaitTime(100);
6条答案
按热度按时间xdnvmnnf1#
是的,LocationRequest建构函式已过时。您可以使用它的静态方法
LocationRequest.create()
来建立位置要求。Kotlin:
java 语:
更新
正如@Shimon所指出的,LocationRequest.PRIORITY_HIGH_ACCURACY现在已弃用,因此请改用Priority.PRIORITY_HIGH_ACCURACY
xhv8bpkk2#
该行现在已弃用:优先级=位置请求。优先级_高_精度
替换为优先级=优先级.优先级_高_精度
d7v8vwbk3#
对于任何在Flutter的
geolocator 8.0.1
中遇到这个错误的人。现在试着编辑FusedLocationClient.java:199
。然后等待作者更新发布包起始日期
结束日期
这是
LocationRequest
类zed5wv104#
更新日期:
常量
PRIORITY_HIGH_ACCURACY
已过时,请改用Priority.PRIORITY_HIGH_ACCURACY
f0brbegy5#
LocationRequest.create().apply{ ... }
现在也不建议使用。请改用
LocationRequest.Builder()
。例如,如下所示:(
locationInterval
、locationFastestInterval
和locationMaxWaitTime
对应于之前使用create()
时使用的值)请在此处阅读更多信息:https://developer.android.com/reference/android/location/LocationRequest.Builder
rggaifut6#