我正在尝试使用 com.google.android.gms:play-services-location:12.0.0
在我的 Android 应用中设置位置更新,但出现以下错误:
LocationRequest constructor is marked as internal and should not be accessed from apps
我的位置更新请求如下所示:
locationClient.requestLocationUpdates(
new LocationRequest()
.setInterval(5000)
.setFastestInterval(1000)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY),
locationCallback,
null
);
我关注了docs和 example , 这样做的方式相同。如果我不应该调用 new LocationRequest()
,那么正确的方法是什么?
最佳答案
使用静态方法LocationRequest create()
.
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(5000);
locationRequest.setFastestInterval(1000);
关于java - LocationRequest 构造函数被标记为内部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49488903/