LocationRequest上的API错误(Google Maps API)

时间:2018-08-25 03:58:10

标签: android api maps

我在实施Google Maps API时出错。

整个源代码的一小部分:

private LocationRequest mLocationRequest;
private GoogleApiClient mGoogleApiClient;

mLocationRequest = new LocationRequest();

错误:

LocationRequest constructor is marked as internal and should not be accessed from apps.
This API has been flagged with a restriction that has not been met.


Examples of API restrictions:
* Method can only be invoked by a subclass
* Method can only be accessed from within the same library (defined by the Gradle library group id)
* Method can only be accessed from tests.

You can add your own API restrictions with the @RestrictTo annotation.

我还在以下位置检查了Google Maps API文档: https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest?hl=ko

谢谢。

-添加- 我看到了类似的问题和答案。但是当我尝试制作LocationRequest create()方法时,错误仍然存​​在。

    public static LocationRequest create() {
        LocationRequest request = new LocationRequest();
        return request;
    }

    private void startLocationService() {
        mLocationRequest = new LocationRequest().create();
        mLocationRequest.setInterval(INTERVAL);
        mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
    }

0 个答案:

没有答案