/** * 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 onResume() { super.onResume(); updateUI(); //checking if Play Store app installed on device GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int errorCode = apiAvailability.isGooglePlayServicesAvailable(getActivity()); if (errorCode != ConnectionResult.SUCCESS) { Dialog errorDialog = apiAvailability .getErrorDialog(getActivity(), errorCode, REQUEST_ERROR, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { getActivity().finish(); } }); errorDialog.show(); } }
/** * 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) { mCameraSource.release(); mCameraSource = null; } } }
@Override protected void onResume() { super.onResume(); //checking if Play Store app installed on device GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int errorCode = apiAvailability.isGooglePlayServicesAvailable(this); if (errorCode != ConnectionResult.SUCCESS) { Dialog errorDialog = apiAvailability .getErrorDialog(this, errorCode, REQUEST_ERROR, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); errorDialog.show(); } }
public static boolean checkPlayServices(Activity context) { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(context, resultCode, 9000).show(); } else { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(context.getResources().getString(R.string.app_name)); alert.setCancelable(false); alert.setMessage(R.string.play_services_warning); alert.setPositiveButton("Exit", (dialog, which) -> System.exit(0)); } return false; } return true; }
/** * 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; } } }
/** * Display an error dialog showing that Google Play Services is missing * or out of date. * * @param connectionStatusCode code describing the presence (or lack of) * Google Play Services on this device. */ void showGooglePlayServicesAvailabilityErrorDialog( final int connectionStatusCode) { if (mProgress != null && mProgress.isShowing()) { mProgress.dismiss(); } try { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); Dialog dialog = apiAvailability.getErrorDialog( getActivity(), connectionStatusCode, ConstantValues.REQUEST_GOOGLE_PLAY_SERVICES); dialog.show(); } catch (Exception e) { Utils.showNotReportableErrorDialog(getActivity(), e.getMessage(), ""); } }
/** * 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; } } }
public static boolean checkPlayServices(Activity context) { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(context, resultCode, 9000).show(); } else { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(""); alert.setMessage(""); alert.setPositiveButton("EXIT", (dialog, which) -> System.exit(0)); } return false; } return true; }
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { // Called whenever the API client fails to connect. Log.i(TAG, "GoogleApiClient connection failed: " + connectionResult.toString()); if (!connectionResult.hasResolution()) { // show the localized error dialog. GoogleApiAvailability.getInstance().getErrorDialog(activity, connectionResult.getErrorCode(), 0).show(); return; } // The failure has a resolution. Resolve it. // Called typically when the app is not yet authorized, and an // authorization // dialog is displayed to the user. try { connectionResult.startResolutionForResult(activity, CONNECTION_FAILED_POPUP); } catch (IntentSender.SendIntentException e) { Log.e(TAG, "Exception while starting resolution activity", e); } }
/** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(cordova.getActivity()); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(cordova.getActivity(), resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.e(TAG, "This device is not supported for Google Play Services."); javascriptErrorback(0, "This device is not supported for Google Play Services.", mInitCallbackContext); } return false; } return true; }
/** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Log.i(LOG_TAG, "This device is not supported."); finish(); } return false; } return true; }
public LocationEditTextPreference(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.LocationEditTextPreference, 0, 0); try { mMinLength = a.getInteger(R.styleable.LocationEditTextPreference_minLength, DEFAULT_MINIMUM_LOCATION_LENGTH); } finally { a.recycle(); } // Check to see if Google Play services is available. The Place Picker API is available // through Google Play services, so if this is false, we'll just carry on as though this // feature does not exist. If it is true, however, we can add a widget to our preference. GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(getContext()); if (resultCode == ConnectionResult.SUCCESS) { // Add the get current location widget to our location preference setWidgetLayoutResource(R.layout.pref_current_location); } }
/** * Displays the dialog in a modal manner using * {@link GoogleApiAvailability#getErrorDialog(Activity, int, int)}. * @param context the context in which the error was encountered * @param errorCode the error code from Google Play Services */ @Override protected final void handle(final Context context, final int errorCode) { // Assume old dialogs generated by the same error handler are obsolete when an error // with a different error code is encountered. if (mErrorCode != errorCode) { cancelDialog(); } if (mDialog == null) { mDialog = GoogleApiAvailability.getInstance().getErrorDialog( mActivity, errorCode, NO_RESPONSE_REQUIRED); mErrorCode = errorCode; } // This can happen if |errorCode| is ConnectionResult.SERVICE_INVALID. if (mDialog != null) { mDialog.show(); } sErrorHandlerActionHistogramSample.record(ERROR_HANDLER_ACTION_MODAL_DIALOG); }
@Override public void onResume() { super.onResume(); GoogleApiAvailability apiAvailablity = GoogleApiAvailability.getInstance(); int errorCode = apiAvailablity.isGooglePlayServicesAvailable(getContext()); if (errorCode != ConnectionResult.SUCCESS) { Dialog errorDialog = apiAvailablity.getErrorDialog(getActivity(), errorCode, REQUEST_ERROR, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { getActivity().finish(); } }); errorDialog.show(); } }
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { if (mProgress != null) { mProgress.dismiss(); } secureBkGDriveFolderPreference.setEnabled(false); if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(BackupRestorePreferenceFragment.this.getActivity(), ConstantValues.REQUEST_GDRIVE_AUTHORIZATION); } catch (IntentSender.SendIntentException e) { // Unable to resolve, message user appropriately } } else { GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), connectionResult.getErrorCode(), 0).show(); } }
private boolean checkPlayServicesPrereq() { GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance(); int result = googleAPI.isGooglePlayServicesAvailable(this); if (result != ConnectionResult.SUCCESS) { if (googleAPI.isUserResolvableError(result)) { googleAPI.getErrorDialog(this, result, 0).show(); Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "PlayServices update required"); Answers.getInstance().logCustom(new CustomEvent("PlayServices update required")); } else { playServicesErrorToast.show(); Crashlytics.log(Log.ERROR, MainActivity.class.getSimpleName(), "PlayServices incompatible"); Answers.getInstance().logCustom(new CustomEvent("PlayServices incompatible")); } return false; } Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "PlayServices compatible"); return true; }
/** * 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(getContext()); if (code != ConnectionResult.SUCCESS) { Dialog dlg = GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), code, 0); dlg.show(); } if (mCameraSource != null) { try { mPreview.start(mCameraSource, mOcrGraphicOverlay); } 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( getActivity()); if (code != ConnectionResult.SUCCESS) { Dialog dlg = GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), 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; } } }
/** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ public static boolean checkPlayServices(AppCompatActivity activity, int PLAY_SERVICES_RESOLUTION_REQUEST) { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { MaterialDialog dialog = new MaterialDialog.Builder(activity) .content("This device is not supported.") .show(); } return false; } return true; }
/** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; }
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { DebugLog.logMethod(); DebugLog.logMessage("ConnectionResult: " + connectionResult.toString()); DebugLog.logMessage("ConnectionResult error: " + connectionResult.getErrorCode() + "\n" + connectionResult.getErrorMessage()); if (!connectionResult.hasResolution()) { GoogleApiAvailability.getInstance() .getErrorDialog(getActivity(), connectionResult.getErrorCode(), 0) .show(); return; } try { connectionResult.startResolutionForResult(getActivity(), Constants.CONNECTION_RESOLUTION_REQUEST_CODE); connectionFailed = true; } catch (IntentSender.SendIntentException e) { // Unable to resolve, message user appropriately e.printStackTrace(); DebugLog.logMessage(e.getMessage()); Utilities.showToast(getActivity(), getString(R.string.google_drive_no_resolution)); } }
@Override protected void onResume() { super.onResume(); GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int errorCode = apiAvailability.isGooglePlayServicesAvailable(this); if (errorCode != ConnectionResult.SUCCESS) { Dialog errorDialog = apiAvailability.getErrorDialog(this, errorCode, REQUEST_ERROR, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { // Leave if services are unavailable. finish(); } }); errorDialog.show(); } }
private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, 9000, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }).show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; }
@SuppressLint("LongLogTag") private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, 9000, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }).show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; }
/** * 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<uses-permission android:name="android.permission.CAMERA" />. 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); } catch (IOException e) { Log.e(TAG, "Unable to start camera source.", e); mCameraSource.release(); mCameraSource = null; } } }
private Observable<Boolean> checkPlayServicesAvailable() { return Observable.create(new ObservableOnSubscribe<Boolean>() { @Override public void subscribe(ObservableEmitter<Boolean> e) throws Exception { final Activity activity = activityReference.get(); if (activity != null) { final GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); final int status = apiAvailability.isGooglePlayServicesAvailable(activity); if (status != ConnectionResult.SUCCESS) { e.onError(new PlayServicesNotAvailableException()); } else { e.onNext(true); e.onComplete(); } } } }); }
private static JobManager configureJobManager(Context context) { Configuration.Builder builder = new Configuration.Builder(context) .minConsumerCount(1)//always keep at least one consumer alive .maxConsumerCount(3)//up to 3 consumers at a time .loadFactor(3)//3 jobs per consumer .consumerKeepAlive(120)//wait 2 minutes .customLogger(customLogger); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.scheduler(FrameworkJobSchedulerService.createSchedulerFor(context, SchedulerJobService.class), true); } else { int enableGcm = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context); if (enableGcm == ConnectionResult.SUCCESS) { builder.scheduler(GcmJobSchedulerService.createSchedulerFor(context, GcmJobSchedulerService.class), true); } } return new JobManager(builder.build()); }
public boolean isGooglePlayServicesAvailable() { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int code = googleApiAvailability.isGooglePlayServicesAvailable(context); if (code != ConnectionResult.SUCCESS) { if (googleApiAvailability.isUserResolvableError(code)) { googleApiAvailability.getErrorDialog(context, code, PLAY_SERVICE_RESOLUTION_REQUEST, this); } else { showLog("THIS DEVICE IS NOT SUPPORTED"); Util.killAppProccess(); } showLog("isGooglePlayServicesAvailable - " + "false"); return false; } showLog("isGooglePlayServicesAvailable - " + "true"); return true; }
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { Toast.makeText(this, "onConnectionFailed:" + connectionResult.getErrorMessage(), Toast.LENGTH_SHORT).show(); // Viene chiamata nel caso la connect fallisca ad esempio // non è ancora stata data autorizzaiozne alla applicazione corrente if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE); } catch (IntentSender.SendIntentException e) { // Unable to resolve, message user appropriately } } else { GoogleApiAvailability.getInstance().getErrorDialog(this, connectionResult.getErrorCode(), 0).show(); } }
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { Log.i(TAG, "onConnectionFailed:" + connectionResult.getErrorMessage()); // Viene chiamata nel caso la connect fallisca ad esempio // non è ancora stata data autorizzaiozne alla applicazione corrente if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE); } catch (IntentSender.SendIntentException e) { // Unable to resolve, message user appropriately } } else { GoogleApiAvailability.getInstance().getErrorDialog(this, connectionResult.getErrorCode(), 0).show(); } }
@Override public void onConnectionFailed(@NonNull ConnectionResult result) { if (!result.hasResolution()) { GoogleApiAvailability.getInstance().getErrorDialog(activity, result.getErrorCode(), 0).show(); return; } try { result.startResolutionForResult(activity, REQUEST_CODE_RESOLUTION); } catch (IntentSender.SendIntentException e) { uploadFailed(); } }
/** * Check that Google Play services APK is installed and up to date. * @return true if Google Play Services is available and up to date on this device, false otherwise. */ public static boolean isGooglePlayServicesAvailable(Context context) { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); final int connectionStatusCode = apiAvailability.isGooglePlayServicesAvailable(context); return connectionStatusCode == ConnectionResult.SUCCESS; }
/** * Attempt to resolve a missing, out-of-date, invalid or disabled Google * Play Services installation via a user dialog, if possible. */ public static void acquireGooglePlayServices(Context context) { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); final int connectionStatusCode = apiAvailability.isGooglePlayServicesAvailable(context); if (apiAvailability.isUserResolvableError(connectionStatusCode)) { Log.e("Error","Connection Status Code"+connectionStatusCode); } }