无法解析方法getLocationSettingsStates()

时间:2016-08-05 15:54:10

标签: google-api geolocation location android-googleapiclient

我正在尝试使用Google Play服务位置API在我的APP中使用本地化。

protected void createLocationRequest() {

    // Create an instance of GoogleAPIClient.
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }

    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);
    mLocationRequest.setFastestInterval(5000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
            .addLocationRequest(mLocationRequest);

    PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());

    final LocationSettingsStates states = result.getLocationSettingsStates();

}

我想已经导入了所有需要的库,无论如何AndroidStudio通知&#39;无法解析方法getLocationSettingsStates()&#39;。 我没有得到其他错误。 我无法弄清楚这一点。

1 个答案:

答案 0 :(得分:0)

resultPendingResult<LocationSettingsResult>,而不是实现LocationSettingsResult的{​​{1}}。您需要执行以下操作:

getLocationSettingsStates()