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(); } }
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 openAutocompleteActivity() { try { // The autocomplete activity requires Google Play Services to be available. The intent // builder checks this and throws an exception if it is not the case. Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN) .build(this); startActivityForResult(intent, REQUEST_CODE_AUTOCOMPLETE); } catch (GooglePlayServicesRepairableException e) { // Indicates that Google Play Services is either not installed or not up to date. Prompt // the user to correct the issue. GoogleApiAvailability.getInstance().getErrorDialog(this, e.getConnectionStatusCode(), 0 /* requestCode */).show(); } catch (GooglePlayServicesNotAvailableException e) { // Indicates that Google Play Services is not available and the problem is not easily // resolvable. String message = "Google Play Services is not available: " + GoogleApiAvailability.getInstance().getErrorString(e.errorCode); Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); } }
private void openAutocompleteActivity() { try { // The autocomplete activity requires Google Play Services to be available. The intent // builder checks this and throws an exception if it is not the case. Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN) .build(this); startActivityForResult(intent, REQUEST_CODE_AUTOCOMPLETE); } catch (GooglePlayServicesRepairableException e) { // Indicates that Google Play Services is either not installed or not up to date. Prompt // the user to correct the issue. GoogleApiAvailability.getInstance().getErrorDialog(this, e.getConnectionStatusCode(), 0 /* requestCode */).show(); } catch (GooglePlayServicesNotAvailableException e) { // Indicates that Google Play Services is not available and the problem is not easily // resolvable. String message = "Google Play Services is not available: " + GoogleApiAvailability.getInstance().getErrorString(e.errorCode); Log.e(TAG, message); Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); } }
@Override protected String doInBackground(Void... params) { AdvertisingIdClient.Info idInfo = null; try { idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } String advertId = null; try{ advertId = idInfo.getId(); }catch (Exception e){ e.printStackTrace(); } return advertId; } @Override
@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 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 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(); } }
@Override public void afterTextChanged(Editable s) { String location = s.toString(); if (TextUtils.isEmpty(location)) return; if (location.equals(oldLocation)) return; try { Intent build = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN).zzh(s.toString()). build((Activity) context); startActivityForResult(build, AUTO_COMP_REQ_CODE); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } oldLocation = location; }
startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace();