LocationRequest构造函数标记为内部 [英] LocationRequest constructor is marked as internal

查看:150
本文介绍了LocationRequest构造函数标记为内部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 com.google.android.gms:play-services-location:12.0.0 在我的Android应用中设置位置更新,但我收到以下错误:

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:


LocationRequest构造函数被标记为内部,不应从应用程序访问

LocationRequest constructor is marked as internal and should not be accessed from apps

我的位置更新请求如下所示:

My location updates request looks like this:

locationClient.requestLocationUpdates(
    new LocationRequest()
        .setInterval(5000)
        .setFastestInterval(1000)
        .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY),
    locationCallback,
    null
);

我跟着 docs 示例,以同样的方式执行。如果我不应该调用新的LocationRequest(),那么正确的方法是什么?

I have followed the docs and 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?

推荐答案

使用静态方法 LocationRequest create()

 LocationRequest locationRequest = LocationRequest.create();
 locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
 locationRequest.setInterval(5000);
 locationRequest.setFastestInterval(1000);

这篇关于LocationRequest构造函数标记为内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆