/** * Invokes whatever external code is necessary to obtain a textual description of an error * code produced by {@link #checkGooglePlayServicesAvailable(Context)}. * @param errorCode The code to check * @return a textual description of the error code */ protected String describeError(final int errorCode) { return GoogleApiAvailability.getInstance().getErrorString(errorCode); } }
public boolean checkPlayServices() { int resultCode = mGoogleApiAvailability.isGooglePlayServicesAvailable(mContext); if (resultCode != ConnectionResult.SUCCESS) { String errorString = mGoogleApiAvailability.getErrorString(resultCode); if (mGoogleApiAvailability.isUserResolvableError(resultCode)) { Log.w(TAG, errorString); } else { Log.e(TAG, "This device is not supported. " + errorString); } return false; } return true; }
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(); } }
String str = GoogleApiAvailability.getInstance().getErrorString(code); Toast.makeText(this, str, Toast.LENGTH_LONG).show();