public static boolean isGcmApiSupported(Context context) { try { if (!checkedServiceEnabled) { checkedServiceEnabled = true; setServiceEnabled(context, GCM_IN_CLASSPATH); } return GCM_IN_CLASSPATH && GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS && isGcmServiceRegistered(context) == ConnectionResult.SUCCESS; } catch (Throwable t) { // seeing sometimes a DeadObjectException, return false, we can't do anything in this case // still sometimes seeing a NoClassDefFoundError here if (BuildConfig.DEBUG) { CAT.w(t.getMessage()); } return false; } }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
protected boolean readyToGo() { GoogleApiAvailability checker= GoogleApiAvailability.getInstance(); int status=checker.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { if (getVersionFromPackageManager(this)>=2) { return(true); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } } else if (checker.isUserResolvableError(status)) { ErrorDialogFragment.newInstance(status) .show(getFragmentManager(), TAG_ERROR_DIALOG_FRAGMENT); } else { Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); finish(); } return(false); }
/** * Starts or restarts the camera source, if it exists. If the camera source doesn't exist yet * (e.g., because onResume was called before the camera source was created), this will be called * again when the camera source is created. */ private void startCameraSource() { // check that the device has play services available. int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( getApplicationContext()); if (code != ConnectionResult.SUCCESS) { Dialog dlg = GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS); dlg.show(); } if (mCameraSource != null) { try { mPreview.start(mCameraSource, mGraphicOverlay); } catch (IOException e) { Log.e(TAG, "Unable to start camera source.", e); mCameraSource.release(); mCameraSource = null; } } }
/** * Starts or restarts the camera source, if it exists. If the camera source doesn't exist yet * (e.g., because onResume was called before the camera source was created), this will be called * again when the camera source is created. */ private void startCameraSource() throws SecurityException { // Check that the device has play services available. int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( getApplicationContext()); if (code != ConnectionResult.SUCCESS) { Dialog dlg = GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS); dlg.show(); } if (mCameraSource != null) { try { mPreview.start(mCameraSource, mGraphicOverlay); } catch (IOException e) { Log.e(TAG, "Unable to start camera source.", e); mCameraSource.release(); mCameraSource = null; } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mToken = MusicPlayer.bindToService(this, this); mPlaybackStatus = new PlaybackStatus(this); //make volume keys change multimedia volume even if music is not playing now setVolumeControlStream(AudioManager.STREAM_MUSIC); try { playServicesAvailable = GoogleApiAvailability .getInstance().isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS; } catch (Exception ignored) { } if (playServicesAvailable) initCast(); }
@Test public void setIsGooglePlayServicesAvailable() { //Given an expected and injected ConnectionResult code final ShadowGoogleApiAvailability shadowGoogleApiAvailability = Shadows.shadowOf(GoogleApiAvailability.getInstance()); final int expectedCode = ConnectionResult.SUCCESS; shadowGoogleApiAvailability.setIsGooglePlayServicesAvailable(expectedCode); //When getting the actual ConnectionResult code final int actualCode = GoogleApiAvailability.getInstance() .isGooglePlayServicesAvailable(roboContext); //Then verify that we got back our expected code and not the default one. assertThat(actualCode) .isEqualTo(expectedCode); }