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 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) } }