谷歌地图v2中是否弃用了“构造函数LocationRequest()”?
我最近偶然发现了这条消息,我很确定这个构造函数在 18.0.0 之前的版本中没有被弃用,但我也找不到任何地方也找不到这个构造函数已被弃用的信息。
我们应该使用什么来代替,有没有另一种方法来创建一个locationRequest?
回答
是的,不推荐使用 LocationRequest 构造函数。您可以使用其静态方法LocationRequest.create()来创建位置请求。
科特林:
locationRequest = LocationRequest.create().apply {
interval = 100
fastestInterval = 50
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
maxWaitTime= 100
}
爪哇:
locationRequest = LocationRequest.create()
.setInterval(100)
.setFastestInterval(3000)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setMaxWaitTime(100);
- I think after version 18.0.0 constructor was deprecated. LocationRequest.create() always were there to create a request, however after version 18 they have added `setWaitForAccurateLocation(true)` to your LocationRequest.