Привет. Я получаю информацию о текущем местоположении с помощью API Google Place.
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