本文整理匯總了Java中com.google.android.gms.location.places.Places類的典型用法代碼示例。如果您正苦於以下問題:Java Places類的具體用法?Java Places怎麽用?Java Places使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Places類屬於com.google.android.gms.location.places包,在下文中一共展示了Places類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: refreshPlacesData
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
public void refreshPlacesData(){
Uri uri = PlacesContract.PlaceEntry.CONTENT_URI;
Cursor dataCursor = getContentResolver().query(uri,
null,
null,
null,null,null);
if (dataCursor==null||dataCursor.getCount()==0) return;
List<String> placeIds = new ArrayList<String>();
while (dataCursor.moveToNext()){
placeIds.add(dataCursor.getString(dataCursor.getColumnIndex(PlacesContract.PlaceEntry.COLUMN_PLACE_ID)));
}
PendingResult<PlaceBuffer> placeBufferPendingResult = Places.GeoDataApi.getPlaceById(mClient,
placeIds.toArray(new String[placeIds.size()]));
placeBufferPendingResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
mAdapter.swapPlaces(places);
mGeofencing.updateGeofencesList(places);
if (mIsEnabled) mGeofencing.registerAllGeofences();
}
});
}
示例2: getAutocomplete
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
private ArrayList<AutocompletePrediction> getAutocomplete(CharSequence constraint) {
if (mGoogleApiClient.isConnected()) {
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mPlaceFilter);
AutocompletePredictionBuffer autocompletePredictions = results
.await(60, TimeUnit.SECONDS);
final Status status = autocompletePredictions.getStatus();
if (!status.isSuccess()) {
Toast.makeText(getContext(), "Error contacting API: " + status.toString(),
Toast.LENGTH_SHORT).show();
autocompletePredictions.release();
return null;
}
return DataBufferUtils.freezeAndClose(autocompletePredictions);
}
return null;
}
示例3: initThings
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
private void initThings() {
loadingManager = new LoadingManager(this);
searchPresenter = new SearchPresenter(this);
notificationManager = new NotificationManager(this);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 0 /* clientId */, this)
.addApi(Places.GEO_DATA_API)
.build();
autoCompleteTextView.setOnItemClickListener(this);
autoCompleteTextView.addTextChangedListener(this);
autoCompleteTextView.setOnEditorActionListener(this);
createPermissionListener();
Dexter.checkPermission(locationPermissionListener, Manifest.permission.ACCESS_COARSE_LOCATION);
}
示例4: getAutocompleteResults
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
public Observable<PlacePrediction> getAutocompleteResults(final GoogleApiClient mGoogleApiClient, final String query, final LatLngBounds bounds) {
return Observable.create(new Observable.OnSubscribe<PlacePrediction>() {
@Override
public void call(Subscriber<? super PlacePrediction> subscriber) {
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, query,
bounds, null);
AutocompletePredictionBuffer autocompletePredictions = results
.await(60, TimeUnit.SECONDS);
final Status status = autocompletePredictions.getStatus();
if (!status.isSuccess()) {
autocompletePredictions.release();
subscriber.onError(null);
} else {
for (AutocompletePrediction autocompletePrediction : autocompletePredictions) {
subscriber.onNext(
new PlacePrediction(
autocompletePrediction.getPlaceId(),
autocompletePrediction.getDescription()
));
}
autocompletePredictions.release();
subscriber.onCompleted();
}
}
});
}
示例5: getCompleteResult
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
public Observable<PointOfInterest> getCompleteResult(final GoogleApiClient mGoogleApiClient, final String id) {
return Observable.create(new Observable.OnSubscribe<PointOfInterest>() {
@Override
public void call(final Subscriber<? super PointOfInterest> subscriber) {
final PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, id);
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
places.release();
subscriber.onError(null);
} else {
subscriber.onNext(PointOfInterest.fromPlace(places.get(0)));
places.close();
subscriber.onCompleted();
}
}
});
}
});
}
示例6: onCreate
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
ButterKnife.bind(this);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 0, this)
.addApi(Places.GEO_DATA_API)
.build();
mDataManager = PickrApplication.get(this).getComponent().dataManager();
mSubscriptions = new CompositeSubscription();
mLocationProvider = new ReactiveLocationProvider(this);
mProgressDialog = DialogFactory.createProgressDialog(this, R.string.dialog_text_getting_location);
setupToolbar();
setupRecyclerView();
retrieveDeviceCurrentLocation();
}
示例7: getAutocomplete
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
private ArrayList<AutocompletePrediction> getAutocomplete(CharSequence constraint) {
if (mGoogleApiClient.isConnected()) {
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mPlaceFilter);
AutocompletePredictionBuffer autocompletePredictions = results.await(60, TimeUnit.SECONDS);
final Status status = autocompletePredictions.getStatus();
if (!status.isSuccess()) {
Toast.makeText(getContext(), "Error contacting API: " + status.toString(),
Toast.LENGTH_SHORT).show();
autocompletePredictions.release();
return null;
}
return DataBufferUtils.freezeAndClose(autocompletePredictions);
}
return null;
}
示例8: callPlaceDetectionApi
import com.google.android.gms.location.places.Places; //導入依賴的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();
}
});
}
示例9: PlaceAutoCompleteHelper
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
public PlaceAutoCompleteHelper(AutoCompleteTextView ... act, FragmentActivity fa) {
Context ctx = act[0].getContext();
mGoogleApiClient = new GoogleApiClient.Builder(ctx)
.enableAutoManage(fa, 0, this)
.addApi(Places.GEO_DATA_API)
.addApi(LocationServices.API)
.build();
mAdapter = new PlaceAutoCompleteAdapter(ctx, mGoogleApiClient,
null);
for (AutoCompleteTextView ac:act) {
ac.setOnItemClickListener(mAutocompleteClickListener);
ac.setAdapter(mAdapter);
ac.setOnFocusChangeListener(this);
}
placeIcon = act[0].getContext().getResources().getDrawable(R.drawable.ic_map_marker);
}
示例10: getAutocomplete
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
private ArrayList<AutocompletePrediction> getAutocomplete(CharSequence constraint) {
if (mGoogleApiClient.isConnected()) {
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mPlaceFilter);
AutocompletePredictionBuffer autocompletePredictions = results
.await(60, TimeUnit.SECONDS);
final Status status = autocompletePredictions.getStatus();
if (!status.isSuccess()) {
if (callback != null) callback.onSuggestFail(status);
autocompletePredictions.release();
return null;
}
return DataBufferUtils.freezeAndClose(autocompletePredictions);
}
return null;
}
示例11: getCurrentPlace
import com.google.android.gms.location.places.Places; //導入依賴的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();
}
});
}
示例12: callPlaceDetectionApi
import com.google.android.gms.location.places.Places; //導入依賴的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();
}
});
}
示例13: callPlaceDetectionApi2
import com.google.android.gms.location.places.Places; //導入依賴的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();
}
});
}
示例14: getLocation
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
private void getLocation() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
mLocationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval(10 * 1000)
.setFastestInterval(1 * 1000);
}
示例15: onCreate
import com.google.android.gms.location.places.Places; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
mAuth = FirebaseAuth.getInstance();
GoogleApiClient apiClient;
apiClient = new GoogleApiClient.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
JournalPageAdapter pageAdapter = new JournalPageAdapter(getSupportFragmentManager());
viewPager.setAdapter(pageAdapter);
// tabLayout.setupWithViewPager(viewPager);
viewPager.addOnPageChangeListener(pageListener);
bottomTabs.setOnNavigationItemSelectedListener(bottomTabsSelected);
}