@Test public void getErrorDialog() { assertNotNull(GooglePlayServicesUtil.getErrorDialog( ConnectionResult.SERVICE_MISSING, new Activity(), 0)); assertNull(GooglePlayServicesUtil.getErrorDialog( ConnectionResult.SUCCESS, new Activity(), 0)); assertNotNull(GooglePlayServicesUtil.getErrorDialog( ConnectionResult.SERVICE_MISSING, new Activity(), 0, null)); assertNull(GooglePlayServicesUtil.getErrorDialog( ConnectionResult.SUCCESS, new Activity(), 0, null)); }
private static boolean isGooglePlayServicesAvailable(Context context) { return GooglePlayServicesUtil. isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS; } }
@Test public void getOpenSourceSoftwareLicenseInfo_defaultNotNull() { assertNotNull(GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo( RuntimeEnvironment.application)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mShouldFinishOnStop = false; setContentView(R.layout.activity_sign_in); activityComponent().inject(this); ButterKnife.bind(this); mSignInPresenter.attachView(this); setSignInButtonEnabled(false); int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resultCode == ConnectionResult.SUCCESS) { setSignInButtonEnabled(true); } else if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil .getErrorDialog(resultCode, this, REQUEST_CODE_PLAY_SERVICES) .show(); } else { showNoPlayServicesError(); Timber.e("This device doesn't support Play Services"); } String popUpMessage = getIntent().getStringExtra(EXTRA_POPUP_MESSAGE); if (popUpMessage != null) { DialogFactory.createSimpleOkErrorDialog(this, popUpMessage).show(); } }
@Override public void onResume() { Log.d(TAG, "onResume"); super.onResume(); int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resultCode == ConnectionResult.SERVICE_MISSING || resultCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED || resultCode == ConnectionResult.SERVICE_DISABLED) { Dialog googlePlayErrorDialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 0); if (googlePlayErrorDialog != null) { googlePlayErrorDialog.show(); } } // Setup listeners mBleManager.setBleListener(this); registerEnabledSensorListeners(true); // Setup send data task if (!isSensorPollingEnabled) { sendDataHandler.postDelayed(mPeriodicallySendData, kSendDataInterval); isSensorPollingEnabled = true; } }
/** * Check that Google Play services APK is installed and up to date. */ private boolean checkGooglePlayServicesAvailable() { final int connectionStatusCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(this); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode); return false; } return true; }
private void init(final Activity activity) { // If the client has already been created, ensure connected and return. if (sGoogleApiClient != null) { if (!sGoogleApiClient.isConnected()) sGoogleApiClient.connect(); return; } int errorCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity); // If the correct Google Play Services are available, connect and return. if (errorCode == ConnectionResult.SUCCESS) { GoogleApiCallbacks googleApiCallbacks = new GoogleApiCallbacks(); sGoogleApiClient = new GoogleApiClient.Builder(activity.getApplicationContext()) .addConnectionCallbacks(googleApiCallbacks) .addOnConnectionFailedListener(googleApiCallbacks) .addApi(LocationServices.API) .build(); sGoogleApiClient.connect(); return; } // If the correct Google Play Services are not available, redirect to proper solution. if (GooglePlayServicesUtil.isUserRecoverableError(errorCode)) { GoogleApiAvailability.getInstance() .getErrorDialog(activity, errorCode, ACTIVITY_REQUEST_CODE) .show(); return; } if (Log.isLoggable(Log.ERROR)) Log.e("Cannot update Google Play Services: " + errorCode); }
private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { //finish(); } return false; } return true; }
@Override public void onResume() { MainActivity.info("MAIN: resume."); super.onResume(); // deal with wake lock if (!state.wakeLock.isHeld() && state.screenLocked) { MainActivity.info("acquire wake lock"); state.wakeLock.acquire(); } final int serviceAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); info("GooglePlayServicesAvailable: " + serviceAvailable); if (serviceAvailable != ConnectionResult.SUCCESS && !playServiceShown) { error("service not available! " + serviceAvailable); final Dialog dialog = GooglePlayServicesUtil.getErrorDialog(serviceAvailable, this, 0); dialog.show(); playServiceShown = true; } }
private boolean isGooglePlayServicesAvailable() { if(this.playServicesAvailable != null){ return this.playServicesAvailable; } final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode); return this.playServicesAvailable = Boolean.FALSE; } else if (connectionStatusCode != ConnectionResult.SUCCESS ) { return this.playServicesAvailable = Boolean.FALSE; } return this.playServicesAvailable = Boolean.TRUE; }
private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(app); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, activity, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Log.i(TAG, "This device is not supported."); } return false; } return true; }
public void run() { Dialog dialog = GooglePlayServicesUtil.getErrorDialog( connectionStatusCode, MainActivity.this, REQUEST_GOOGLE_PLAY_SERVICES); dialog.show(); } });
/** * Retrieves a map if the map fragment parameter is null. * <p> * If there is an error tries to solve it checking if it was because of * "Google Play Services" sending the corresponding intent. * * @param mMap map fragment to check if the map is already initialized * @return initialized map fragment */ private GoogleMap retrieveMap(GoogleMap mMap) { // Do a null check to confirm that we have not already instantiated the map. mMapFailed = false; if (mMap == null) { mMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)) .getMap(); // Check if we were successful in obtaining the map. if (mMap == null) { int status = GooglePlayServicesUtil .isGooglePlayServicesAvailable(mApplicationContext); if (status != ConnectionResult.SUCCESS) { enableUIElements(false); Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, getActivity(), OTPApp.CHECK_GOOGLE_PLAY_REQUEST_CODE); dialog.show(); mMapFailed = true; } } } return mMap; }
@Test public void isGooglePlayServicesAvailable_defaultServiceMissing() { assertEquals(ConnectionResult.SERVICE_MISSING, GooglePlayServicesUtil.isGooglePlayServicesAvailable(RuntimeEnvironment.application)); } }
public static boolean showDialogIfNotAvailable(FragmentActivity activity) { removeDialog(activity); int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity); boolean available = status == ConnectionResult.SUCCESS; if (!available) { if (GooglePlayServicesUtil.isUserRecoverableError(status)) { showDialog(status, activity); } else { ToastHelper.showToast(activity.getApplication(), "Google Play services not available"); } } return available; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.legal); TextView legal=(TextView)findViewById(R.id.legal); legal.setText(GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this)); } }
private boolean isGooglePlayInstalled() { int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, this, ACTION_PLAY_SERVICES_DIALOG).show(); } else { Toast.makeText(getApplicationContext(), "Google Play Service is not installed", Toast.LENGTH_SHORT).show(); finish(); } return false; } return true; }
@Override public void run() { Dialog dialog = GooglePlayServicesUtil.getErrorDialog( connectionStatusCode, FirstrunActivity.this, GMConstants.REQUEST_GOOGLE_PLAY_SERVICES); dialog.show(); } });
final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity); errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode, activity, requestCode, null); if (errorDialog == null) {
@Test public void canRedirectStaticMethodToImplementation() { ShadowGooglePlayServicesUtil.provideImpl(mockGooglePlayServicesUtil); when(mockGooglePlayServicesUtil.isGooglePlayServicesAvailable( any(Context.class))).thenReturn(ConnectionResult.INTERNAL_ERROR); assertEquals(ConnectionResult.INTERNAL_ERROR, GooglePlayServicesUtil.isGooglePlayServicesAvailable(RuntimeEnvironment.application)); }