java LocationRequest 构造函数被标记为内部
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49488903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LocationRequest constructor is marked as internal
提问by Duncan Luk
I'm trying to set up location updates in my Android app using com.google.android.gms:play-services-location:12.0.0
, but I'm getting the following error:
我正在尝试使用 设置我的 Android 应用程序中的位置更新com.google.android.gms:play-services-location:12.0.0
,但出现以下错误:
LocationRequest constructor is marked as internal and should not be accessed from apps
LocationRequest 构造函数被标记为内部,不应从应用程序访问
My location updates request looks like this:
我的位置更新请求如下所示:
locationClient.requestLocationUpdates(
new LocationRequest()
.setInterval(5000)
.setFastestInterval(1000)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY),
locationCallback,
null
);
I have followed the docsand the example, which do it the same way. If I'm not supposed to call new LocationRequest()
, then what is the proper way to do it?
我已经按照文档和示例进行操作,它们的操作方式相同。如果我不应该打电话new LocationRequest()
,那么正确的做法是什么?
回答by ADM
Use static methodLocationRequest create ()
.
使用静态方法LocationRequest create ()
。
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(5000);
locationRequest.setFastestInterval(1000);
回答by Rahul Sharma
LocationRequestinitialization procedure has changed into latest Google Play Service dependencies ( > 12.0.0). Now you can use its create()method to initialize this. e.g.
LocationRequest初始化程序已更改为最新的 Google Play 服务依赖项 (> 12.0.0)。现在你可以使用它的create()方法来初始化它。例如
LocationRequest request = LocationRequest.create();