當前位置: 首頁>>代碼示例>>Java>>正文


Java Places類代碼示例

本文整理匯總了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();
        }
    });
}
 
開發者ID:samagra14,項目名稱:Shush,代碼行數:23,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:23,代碼來源:PlaceAutocompleteAdapter.java

示例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);

}
 
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:18,代碼來源:SearchActivity.java

示例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();
            }
        }
    });
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:31,代碼來源:DataManager.java

示例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();
                    }
                }
            });
        }
    });
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:23,代碼來源:DataManager.java

示例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();
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:21,代碼來源:SearchActivity.java

示例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;
}
 
開發者ID:jotaramirez90,項目名稱:AutocompleteLocation,代碼行數:21,代碼來源:AutoCompleteAdapter.java

示例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();
        }
    });
}
 
開發者ID:addy-org,項目名稱:Addy-Android,代碼行數:17,代碼來源:PlacesAPIActivity.java

示例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);
}
 
開發者ID:agusibrahim,項目名稱:go-jay,代碼行數:17,代碼來源:PlaceAutoCompleteHelper.java

示例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;
}
 
開發者ID:agusibrahim,項目名稱:go-jay,代碼行數:19,代碼來源:PlaceAutoCompleteHelper.java

示例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();
        }
    });
}
 
開發者ID:Pavou,項目名稱:Stalker,代碼行數:20,代碼來源:PlaceFragment.java

示例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();
        }
    });
}
 
開發者ID:Pritom14,項目名稱:Gps,代碼行數:20,代碼來源:Gps4Activity.java

示例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();
        }
    });
}
 
開發者ID:Pritom14,項目名稱:Gps,代碼行數:20,代碼來源:Gps4Activity.java

示例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);

    }
 
開發者ID:webianks,項目名稱:Crimson,代碼行數:18,代碼來源:SearchClinics.java

示例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);
    }
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:21,代碼來源:MainActivity.java


注:本文中的com.google.android.gms.location.places.Places類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。