本文整理汇总了Java中com.google.android.gms.location.places.PlaceLikelihoodBuffer类的典型用法代码示例。如果您正苦于以下问题:Java PlaceLikelihoodBuffer类的具体用法?Java PlaceLikelihoodBuffer怎么用?Java PlaceLikelihoodBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlaceLikelihoodBuffer类属于com.google.android.gms.location.places包,在下文中一共展示了PlaceLikelihoodBuffer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callPlaceDetectionApi
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
private void callPlaceDetectionApi() throws SecurityException {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Log.i(LOG_TAG, String.format("Place '%s' with " +
"likelihood: %g",
placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
}
likelyPlaces.release();
}
});
}
示例2: getCurrentPlace
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
void getCurrentPlace() throws SecurityException {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(placeApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (int i = 0; i < likelyPlaces.getCount() && i < 5; i++) {
PlaceEntry place = new PlaceEntry();
if (likelyPlaces.get(i).getLikelihood() == 0) continue;
place.setName(likelyPlaces.get(i).getPlace().getName().toString());
place.setLatLon(likelyPlaces.get(i).getPlace().getLatLng());
myDataset.add(place);
mAdapter.notifyItemInserted(myDataset.size() - 1);
}
getMapA();
likelyPlaces.release();
}
});
}
示例3: callPlaceDetectionApi
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
private void callPlaceDetectionApi() throws SecurityException {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Log.i(LOG_TAG, String.format("Place '%s' with " +
"likelihood: %g",
placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
display.setText(placeLikelihood.getPlace().getAddress().toString());
messageSending(placeLikelihood.getPlace().getAddress().toString());
break;
}
likelyPlaces.release();
}
});
}
示例4: callPlaceDetectionApi2
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
private void callPlaceDetectionApi2(final String ph_number) throws SecurityException {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Log.i(LOG_TAG, String.format("Place '%s' with " +
"likelihood: %g",
placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
display.setText(placeLikelihood.getPlace().getAddress().toString());
messageSending_individual(ph_number,placeLikelihood.getPlace().getAddress().toString());
break;
}
likelyPlaces.release();
}
});
}
示例5: guessCurrentPlace
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
private void guessCurrentPlace() {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace( mGoogleApiClient, null );
result.setResultCallback( new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult( PlaceLikelihoodBuffer likelyPlaces ) {
PlaceLikelihood placeLikelihood = likelyPlaces.get( 0 );
String content = "";
if( placeLikelihood != null && placeLikelihood.getPlace() != null && !TextUtils.isEmpty( placeLikelihood.getPlace().getName() ) )
content = "Most likely place: " + placeLikelihood.getPlace().getName() + "\n";
if( placeLikelihood != null )
content += "Percent change of being there: " + (int) ( placeLikelihood.getLikelihood() * 100 ) + "%";
mTextView.setText( content );
likelyPlaces.release();
}
});
}
示例6: getCurrentPlace
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
/**
* Returns observable that fetches current place from Places API. To flatmap and auto release
* buffer to {@link com.google.android.gms.location.places.PlaceLikelihood} observable use
* {@link DataBufferObservable}.
*
* @param placeFilter filter
* @return observable that emits current places buffer and completes
*/
public Observable<PlaceLikelihoodBuffer> getCurrentPlace(@Nullable final PlaceFilter placeFilter) {
return getGoogleApiClientObservable(Places.PLACE_DETECTION_API, Places.GEO_DATA_API)
.flatMap(new Func1<GoogleApiClient, Observable<PlaceLikelihoodBuffer>>() {
@Override
public Observable<PlaceLikelihoodBuffer> call(GoogleApiClient api) {
return fromPendingResult(Places.PlaceDetectionApi.getCurrentPlace(api, placeFilter));
}
});
}
示例7: updateMarkers
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
/**
* Adds markers for places nearby the device and turns the My Location feature on or off,
* provided location permission has been granted.
*/
private void updateMarkers() {
if (mMap == null) {
return;
}
if (mLocationPermissionGranted) {
// Get the businesses and other points of interest located
// nearest to the device's current location.
@SuppressWarnings("MissingPermission")
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(@NonNull PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
// Add a marker for each place near the device's current location, with an
// info window showing place information.
String attributions = (String) placeLikelihood.getPlace().getAttributions();
String snippet = (String) placeLikelihood.getPlace().getAddress();
if (attributions != null) {
snippet = snippet + "\n" + attributions;
}
mMap.addMarker(new MarkerOptions()
.position(placeLikelihood.getPlace().getLatLng())
.title((String) placeLikelihood.getPlace().getName())
.snippet(snippet));
}
// Release the place likelihood buffer.
likelyPlaces.release();
}
});
} else {
mMap.addMarker(new MarkerOptions()
.position(mDefaultLocation)
.title(getString(R.string.default_info_title))
.snippet(getString(R.string.default_info_snippet)));
}
}
示例8: isAtGasStationAsync
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
public void isAtGasStationAsync(final CurrentPlaceListener currentPlaceListener) {
if (!LocationHelper.isLocationPermissionAsked && ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LocationHelper.LOCATION_PERMISSION_REQUEST);
Log.e("getting location", "NO PERMISSION");
}
PendingResult<PlaceLikelihoodBuffer> places = Places.PlaceDetectionApi
.getCurrentPlace(googleApiClient, null);
places.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
if (placeLikelihood.getLikelihood() > LIKELIHOOD_ACCEPTABLE) {
List<Integer> types = placeLikelihood.getPlace().getPlaceTypes();
for (int t : types) {
if (t == Place.TYPE_GAS_STATION) {
lastStation = new Station(placeLikelihood.getPlace());
currentPlaceListener.OnIsAtGasStationResult(lastStation);
break;
}
}
}
}
likelyPlaces.release();
}
});
}
示例9: lokasyonCek
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
private void lokasyonCek(final boolean hepsi, final boolean hastahane, final boolean eczane, final boolean cafe, final boolean ibadethane, final boolean okul, final boolean diger) {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
List types=placeLikelihood.getPlace().getPlaceTypes();
Log.i("liste", String.format("Place '%s' has likelihood: %g",
placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
if(hepsi)
konumlar.add(placeLikelihood.getPlace().getName().toString());
else{
if(hastahane && (types.contains(Place.TYPE_HOSPITAL) || types.contains(Place.TYPE_DOCTOR) ||types.contains(Place.TYPE_DENTIST) || types.contains(Place.TYPE_VETERINARY_CARE)))
konumlar.add(placeLikelihood.getPlace().getName().toString());
if(eczane && types.contains(Place.TYPE_PHARMACY))
konumlar.add(placeLikelihood.getPlace().getName().toString());
if(cafe &&( types.contains(Place.TYPE_CAFE) ||(types.contains(Place.TYPE_RESTAURANT) || types.contains(Place.TYPE_NIGHT_CLUB))))
konumlar.add(placeLikelihood.getPlace().getName().toString());
if(ibadethane && (types.contains(Place.TYPE_MOSQUE) || types.contains(Place.TYPE_CHURCH)))
konumlar.add(placeLikelihood.getPlace().getName().toString());
if(okul && (types.contains(Place.TYPE_UNIVERSITY) || types.contains(Place.TYPE_SCHOOL)))
konumlar.add(placeLikelihood.getPlace().getName().toString());
if(diger)
konumlar.add(placeLikelihood.getPlace().getName().toString());
}
}
likelyPlaces.release();
veriAdaptoru.notifyDataSetChanged();
}
});
}
示例10: getCurrentLocation
import com.google.android.gms.location.places.PlaceLikelihoodBuffer; //导入依赖的package包/类
public void getCurrentLocation() {
try {
// On Marshmallow request for permissions first
if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
PERMISSION_ACCESS_FINE_LOCATION);
} else {
return;
}
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION},
PERMISSION_ACCESS_COARSE_LOCATION);
} else {
return;
}
}
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(@NonNull PlaceLikelihoodBuffer likelyPlaces) {
Place place = null;
float max = 0;
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
float likelihood = placeLikelihood.getLikelihood();
if (likelihood > max) {
place = placeLikelihood.getPlace();
max = placeLikelihood.getLikelihood();
}
}
if (place == null) {
Toast.makeText(getApplicationContext(), R.string.note_location_unable, Toast.LENGTH_SHORT).show();
} else {
note.setLocation(place);
refreshLayout();
}
likelyPlaces.release();
}
});
} catch (Exception ex) {
Toast.makeText(getApplicationContext(), R.string.note_location_unable, Toast.LENGTH_SHORT).show();
}
}