在Google Place API中获取位置超时信息?

时间:2019-02-23 12:53:42

标签: android dictionary google-places-api currentlocation

嗨,我正在使用Google Place API获取当前位置的详细信息。

   List<Place.Field> placeFields = Arrays.asList(Place.Field.NAME, Place.Field.LAT_LNG);
        FindCurrentPlaceRequest request =
                FindCurrentPlaceRequest.builder(placeFields).build();

        mPlaceDetectionClient = Places.createClient(this);
        Task<FindCurrentPlaceResponse> placeResponse = mPlaceDetectionClient.findCurrentPlace(request);


        placeResponse.addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                FindCurrentPlaceResponse response = task.getResult();

                    List<Place> placesList = new ArrayList<Place>();

                assert response != null;
                for (PlaceLikelihood placeLikelihood : response.getPlaceLikelihoods()) {
                        placesList.add(placeLikelihood.getPlace());
                    }
                    showAddPropertyNameDialog(AppStringConstants.ADD_NEW_STORE_TAG, placesList.get(0));
                hideLoader();
            } else {
                showDialog(getString(R.string.find_location_fail_msg), "", new DialogType(DialogType.DIALOG_MESSAGE));
            }

        });

但是它总是返回位置超时

com.google.android.gms.common.api.ApiException: 15: Location timeout.

我已将代码迁移到新的api,如下所示。 https://developers.google.com/places/android-sdk/current-place

0 个答案:

没有答案