public void startChooseLocationActivity (Activity activity, Result resultHandler) throws Exception { this.resultHandler = resultHandler; this.activity = activity; PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); try { Intent intent = builder.build(activity); activity.startActivityForResult(intent, PICK_LOCATION); } catch (GooglePlayServicesRepairableException e) { throw new Exception(e.getMessage()); } // Intent intent = new Intent(context, ChatSDKLocationActivity.class); }
private void openGooglePlacePicker() { try { progressDialog.show(); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); Toast.makeText(getActivity(), getString(R.string.toast_google_service_not_work), Toast.LENGTH_LONG).show(); progressDialog.dismiss(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); Toast.makeText(getActivity(), getString(R.string.toast_google_service_not_work), Toast.LENGTH_LONG).show(); progressDialog.dismiss(); } }
private void openGooglePlacePicker() { if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getContext()) == ConnectionResult.SUCCESS) { try { progressDialog.show(); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); progressDialog.dismiss(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); progressDialog.dismiss(); } } else { Toast.makeText(getActivity(), getString(R.string.toast_google_service_not_work), Toast.LENGTH_LONG).show(); } }
builder.setLatLngBounds(bounds); try { startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace();
@Override public void onCardClick(int cardActionId, String cardTag) { if (cardActionId == ACTION_PICK_PLACE) { // BEGIN_INCLUDE(intent) /* Use the PlacePicker Builder to construct an Intent. Note: This sample demonstrates a basic use case. The PlacePicker Builder supports additional properties such as search bounds. */ try { PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder(); Intent intent = intentBuilder.build(getActivity()); // Start the Intent by requesting a result, identified by a request code. startActivityForResult(intent, REQUEST_PLACE_PICKER); // Hide the pick option in the UI to prevent users from starting the picker // multiple times. showPickAction(false); } catch (GooglePlayServicesRepairableException e) { GooglePlayServicesUtil .getErrorDialog(e.getConnectionStatusCode(), getActivity(), 0); } catch (GooglePlayServicesNotAvailableException e) { Toast.makeText(getActivity(), "Google Play Services is not available.", Toast.LENGTH_LONG) .show(); } // END_INCLUDE(intent) } }
@Override public void onFocusChange(View view, boolean b) { // Toast.makeText(getApplicationContext(), "Destination", Toast.LENGTH_SHORT).show(); if (b) { try { // Intent intent = // new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).build(activity); // startActivityForResult(intent, AUTOCOMPLETE_DESTINATITON); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(activity), AUTOCOMPLETE_DESTINATITON); } catch (GooglePlayServicesRepairableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } catch (GooglePlayServicesNotAvailableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } } } });
@Override public void onFocusChange(View view, boolean b) { if (b) { try { // Intent intent = // new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).build(activity); // startActivityForResult(intent, AUTOCOMPLETE_SOURCE); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(activity), AUTOCOMPLETE_SOURCE); } catch (GooglePlayServicesRepairableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } catch (GooglePlayServicesNotAvailableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } } } });
@Override public void onClick(View view) { try { // Intent intent = // new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).build(activity); // startActivityForResult(intent, AUTOCOMPLETE_SOURCE); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(activity), AUTOCOMPLETE_SOURCE); } catch (GooglePlayServicesRepairableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } catch (GooglePlayServicesNotAvailableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } } });
@Override public void onClick(View view) { try { // Intent intent = // new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).build(activity); // startActivityForResult(intent, AUTOCOMPLETE_DESTINATITON); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(activity), AUTOCOMPLETE_DESTINATITON); } catch (GooglePlayServicesRepairableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } catch (GooglePlayServicesNotAvailableException e) { // TODO: Handle the error. // Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); } } });
@Override public void onClick(View v) { PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); try { // Launch the PlacePicker. startActivityForResult(builder.build(MainActivity.this) , REQUEST_PICK_PLACE); } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } } });
@Override public void onClick(View view) { PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); try { startActivityForResult(builder.build(MapActivity.this), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException e) { Log.e(TAG, "onClick: GooglePlayServicesRepairableException: " + e.getMessage() ); } catch (GooglePlayServicesNotAvailableException e) { Log.e(TAG, "onClick: GooglePlayServicesNotAvailableException: " + e.getMessage() ); } } });
private void displayPlacePicker() { if( mGoogleApiClient == null || !mGoogleApiClient.isConnected() ) return; PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); try { startActivityForResult( builder.build((Activity) getApplicationContext()), PLACE_PICKER_REQUEST ); } catch ( GooglePlayServicesRepairableException e ) { Log.d( "PlacesAPI Demo", "GooglePlayServicesRepairableException thrown" ); } catch ( GooglePlayServicesNotAvailableException e ) { Log.d( "PlacesAPI Demo", "GooglePlayServicesNotAvailableException thrown" ); } }
private void pickLocation() { try { PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(this), REQUEST_PLACE_PICKER); } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) { Toast.makeText(this, R.string.placePickerNotAvailable, Toast.LENGTH_SHORT).show(); } }
private void displayPlacePicker() { if( mGoogleApiClient == null || !mGoogleApiClient.isConnected() ) return; PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); try { startActivityForResult( builder.build((Activity) getApplicationContext()), PLACE_PICKER_REQUEST ); } catch ( GooglePlayServicesRepairableException e ) { Log.d( "PlacesAPI Demo", "GooglePlayServicesRepairableException thrown" ); } catch ( GooglePlayServicesNotAvailableException e ) { Log.d( "PlacesAPI Demo", "GooglePlayServicesNotAvailableException thrown" ); } }