B
Benreis61
Fortgeschrittenes Mitglied
- 32
Hallo,
Ich versuche, ein MapApp zu realisieren. Dabei übernehme ich auch Code Snipsel von verschiedenen Quellen.
Unten angegebene Funktion ist so eine. Die Funktion gibt
Log.e(TAG, "getCurrentPlaceLikelihoodslace not found: " aus.
Um den Fehler herauszufinden, muss ich die Funktion verstehen. Das tue ich aber leider zu ca 30%
Wer kann das mir erklären ?
zB Was macht
@SuppressWarnings("MissingPermission") final FindCurrentPlaceRequest request =
FindCurrentPlaceRequest.builder(placeFields).build();
Oder woher nimmt die Funktion die aktuelle Position ?
private void getCurrentPlaceLikelihoods() {
Log.d(TAG, "!!! getCurrentPlaceLikelihoods");
// Use fields to define the data types to return.
List<Place.Field> placeFields = Arrays.asList(Place.Field.NAME, Place.Field.ADDRESS,
Place.Field.LAT_LNG);
// Get the likely places - that is, the businesses and other points of interest that
// are the best match for the device's current location.
@SuppressWarnings("MissingPermission") final FindCurrentPlaceRequest request =
FindCurrentPlaceRequest.builder(placeFields).build();
Task<FindCurrentPlaceResponse> placeResponse = mPlacesClient.findCurrentPlace(request);
placeResponse.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
FindCurrentPlaceResponse response = task.getResult();
// Set the count, handling cases where less than 5 entries are returned.
int count;
if (response.getPlaceLikelihoods().size() < M_MAX_ENTRIES) {
count = response.getPlaceLikelihoods().size();
} else {
count = M_MAX_ENTRIES;
}
int i = 0;
mLikelyPlaceNames = new String[count];
mLikelyPlaceAddresses = new String[count];
mLikelyPlaceAttributions = new String[count];
mLikelyPlaceLatLngs = new LatLng[count];
for (PlaceLikelihood placeLikelihood : response.getPlaceLikelihoods()) {
Place currPlace = placeLikelihood.getPlace();
mLikelyPlaceNames = currPlace.getName();
mLikelyPlaceAddresses = currPlace.getAddress();
mLikelyPlaceAttributions = (currPlace.getAttributions() == null) ?
null : TextUtils.join(" ", currPlace.getAttributions());
mLikelyPlaceLatLngs = currPlace.getLatLng();
String currLatLng = (mLikelyPlaceLatLngs == null) ?
"" : mLikelyPlaceLatLngs.toString();
Log.i(TAG, String.format("Place " + currPlace.getName()
+ " has likelihood: " + placeLikelihood.getLikelihood()
+ " at " + currLatLng));
i++;
if (i > (count - 1)) {
break;
}
}
// COMMENTED OUT UNTIL WE DEFINE THE METHOD
// Populate the ListView
fillPlacesList();
} else {
Exception exception = task.getException();
if (exception instanceof ApiException) {
ApiException apiException = (ApiException) exception;
Log.e(TAG, "getCurrentPlaceLikelihoodslace not found: "
+ apiException.getStatusCode());
}
}
});
}
Ich versuche, ein MapApp zu realisieren. Dabei übernehme ich auch Code Snipsel von verschiedenen Quellen.
Unten angegebene Funktion ist so eine. Die Funktion gibt
Log.e(TAG, "getCurrentPlaceLikelihoodslace not found: " aus.
Um den Fehler herauszufinden, muss ich die Funktion verstehen. Das tue ich aber leider zu ca 30%
Wer kann das mir erklären ?
zB Was macht
@SuppressWarnings("MissingPermission") final FindCurrentPlaceRequest request =
FindCurrentPlaceRequest.builder(placeFields).build();
Oder woher nimmt die Funktion die aktuelle Position ?
private void getCurrentPlaceLikelihoods() {
Log.d(TAG, "!!! getCurrentPlaceLikelihoods");
// Use fields to define the data types to return.
List<Place.Field> placeFields = Arrays.asList(Place.Field.NAME, Place.Field.ADDRESS,
Place.Field.LAT_LNG);
// Get the likely places - that is, the businesses and other points of interest that
// are the best match for the device's current location.
@SuppressWarnings("MissingPermission") final FindCurrentPlaceRequest request =
FindCurrentPlaceRequest.builder(placeFields).build();
Task<FindCurrentPlaceResponse> placeResponse = mPlacesClient.findCurrentPlace(request);
placeResponse.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
FindCurrentPlaceResponse response = task.getResult();
// Set the count, handling cases where less than 5 entries are returned.
int count;
if (response.getPlaceLikelihoods().size() < M_MAX_ENTRIES) {
count = response.getPlaceLikelihoods().size();
} else {
count = M_MAX_ENTRIES;
}
int i = 0;
mLikelyPlaceNames = new String[count];
mLikelyPlaceAddresses = new String[count];
mLikelyPlaceAttributions = new String[count];
mLikelyPlaceLatLngs = new LatLng[count];
for (PlaceLikelihood placeLikelihood : response.getPlaceLikelihoods()) {
Place currPlace = placeLikelihood.getPlace();
mLikelyPlaceNames = currPlace.getName();
mLikelyPlaceAddresses = currPlace.getAddress();
mLikelyPlaceAttributions = (currPlace.getAttributions() == null) ?
null : TextUtils.join(" ", currPlace.getAttributions());
mLikelyPlaceLatLngs = currPlace.getLatLng();
String currLatLng = (mLikelyPlaceLatLngs == null) ?
"" : mLikelyPlaceLatLngs.toString();
Log.i(TAG, String.format("Place " + currPlace.getName()
+ " has likelihood: " + placeLikelihood.getLikelihood()
+ " at " + currLatLng));
i++;
if (i > (count - 1)) {
break;
}
}
// COMMENTED OUT UNTIL WE DEFINE THE METHOD
// Populate the ListView
fillPlacesList();
} else {
Exception exception = task.getException();
if (exception instanceof ApiException) {
ApiException apiException = (ApiException) exception;
Log.e(TAG, "getCurrentPlaceLikelihoodslace not found: "
+ apiException.getStatusCode());
}
}
});
}
Zuletzt bearbeitet: