ApiException apiException: 15 Таймаут местоположения API Google Map для Android - PullRequest
0 голосов
/ 31 марта 2020

Я следовал инструкциям здесь https://developers.google.com/places/android-sdk/client-migration#find_a_place_from_the_users_location, чтобы перейти на SDK New Places.

Однако всякий раз, когда я пытаюсь определить местоположение пользователя, я получаю ApiException 15;

Я серьезно не знаю, что пошло не так. Любая помощь будет высоко ценится.

Вот мой код:

    private void findcurrentLocation(){
        // Use fields to define the data types to return.
        List<Place.Field> placeFields = Arrays.asList(Place.Field.NAME);


        Log.e("calling function","find current location");

        Log.e("calling function2",Place.Field.NAME.name().toString());


        // Use the builder to create a FindCurrentPlaceRequest.
        FindCurrentPlaceRequest request =
                FindCurrentPlaceRequest.builder(placeFields).build();


        Log.e("request",request.toString());
        // Call findCurrentPlace and handle the response (first check that the user has granted permission).
        if (ContextCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            placesClient.findCurrentPlace(request).addOnSuccessListener(((response) -> {
                for (PlaceLikelihood placeLikelihood : response.getPlaceLikelihoods()) {
                    Log.e("Warning", String.format("Place '%s' has likelihood: %f",
                            placeLikelihood.getPlace().getName(),
                            placeLikelihood.getLikelihood()));


//                    textView.append(String.format("Place '%s' has likelihood: %f\n",
//                            placeLikelihood.getPlace().getName(),
//                            placeLikelihood.getLikelihood()));
                }
            })).addOnFailureListener((exception) -> {
                if (exception instanceof ApiException) {
                    ApiException apiException = (ApiException) exception;

                    Log.e("Warning", "Place not found: " + apiException.getStatusCode() + apiException.getLocalizedMessage() + apiException.getCause());
                }
            });
        } else {
            // A local method to request required permissions;
            // See https://developer.android.com/training/permissions/requesting
            getLocationPermission();
        }
    }

Сообщение об ошибке: E / Предупреждение: Место не найдено: 1515: Местоположение timeout.null

...