gpt4 book ai didi

java - LocationRequest 构造函数被标记为内部

转载 作者:IT老高 更新时间:2023-10-28 20:57:06 28 4
gpt4 key购买 nike

我正在尝试使用 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
);

我关注了docsexample , 这样做的方式相同。如果我不应该调用 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/

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