com.google.android.gms.common.GoogleApiAvailability Java Examples

The following examples show how to use com.google.android.gms.common.GoogleApiAvailability. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LicenseAgreementActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public void viewGoogleLicenses(View myview) {
    try {
        if (!appended) {
            final String googleLicense = GoogleApiAvailability.getInstance().getOpenSourceSoftwareLicenseInfo(getApplicationContext());
            if (googleLicense != null) {
                String whiteheader = "<font size=-2 color=white><pre>";
                String whitefooter = "</font></pre>";
                WebView textview = (WebView) findViewById(R.id.webView);
                textview.setBackgroundColor(Color.TRANSPARENT);
                textview.getSettings().setJavaScriptEnabled(false);
                textview.loadDataWithBaseURL("", whiteheader + googleLicense + whitefooter, "text/html", "UTF-8", "");
                appended = true;
                findViewById(R.id.googlelicenses).setVisibility(View.INVISIBLE);
                findViewById(R.id.webView).setVisibility(View.VISIBLE);

            } else {
                UserError.Log.d(TAG, "Nullpointer getting Google License: errorcode:" + GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getApplicationContext()));
                findViewById(R.id.googlelicenses).setVisibility(View.INVISIBLE);
            }
        }
    } catch (Exception e) {
        // meh
    }
}
 
Example #2
Source File: RecognitionGoogleCloud.java    From Saiy-PS with GNU Affero General Public License v3.0 6 votes vote down vote up
private void showPlayServicesError(final int errorCode) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "showPlayServicesError");
    }

    onError(SpeechRecognizer.ERROR_CLIENT);

    switch (errorCode) {

        case UNRECOVERABLE:
            // TODO
            break;
        default:
            final GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
            apiAvailability.showErrorNotification(mContext, errorCode);
            break;
    }
}
 
Example #3
Source File: BarcodeCaptureActivity.java    From flutter_barcode_scanner with MIT License 6 votes vote down vote up
/**
 * 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;
        }
    }
    System.gc();
}
 
Example #4
Source File: MultiTrackerActivity.java    From android-vision with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #5
Source File: JobManagerFactory.java    From OfflineSampleApp with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example #6
Source File: LoginActivity.java    From android with MIT License 6 votes vote down vote up
private boolean checkGooglePlayServices() {
    final GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    final int result = googleApiAvailability.isGooglePlayServicesAvailable(this);
    if (result != ConnectionResult.SUCCESS) {
        if (googleApiAvailability.isUserResolvableError(result)) {
            googleApiAvailability
                    .getErrorDialog(this,
                            result,
                            Const.RequestCodes.AUTH_LOGIN_GOOGLE_RESOLVE)
                    .show();
        }

        return false;
    }

    return true;
}
 
Example #7
Source File: MainActivity.java    From pusher-websocket-android with MIT License 6 votes vote down vote up
private boolean checkPlayServices() {
/**
 * 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.
 */
    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;
}
 
Example #8
Source File: QrActivity.java    From yubikit-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_qr_scan);
    surfaceView = findViewById(R.id.surfaceView);
    if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS) {
        initQrReader();
    } else {
        setResult(GOOGLE_PLAY_SERVICES_UNAVAILABLE);
        finish();
    }

    if (qrReader != null) {
        if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_CAMERA);
        }
    }
}
 
Example #9
Source File: MainActivity.java    From google-services with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: MainActivity.java    From azure-notificationhubs-android with Apache License 2.0 6 votes vote down vote up
/**
 * 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 by Google Play Services.");
            ToastNotify("This device is not supported by Google Play Services.");
            finish();
        }
        return false;
    }
    return true;
}
 
Example #11
Source File: MqttSettingsCodeReaderFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 6 votes vote down vote up
/**
 * 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.
    Context context = getContext();
    if (context == null) {
        return;
    }

    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context.getApplicationContext());
    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;
        }
    }
}
 
Example #12
Source File: LocatrActivity.java    From AndroidProgramming3e with Apache License 2.0 6 votes vote down vote up
@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();
    }
}
 
Example #13
Source File: OrderListActivity.java    From Pharmacy-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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() {
    final int PLAY_SERVICES_RESOLUTION_REQUEST = 9002;

    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 {
            Timber.i("Play services: This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}
 
Example #14
Source File: Utils.java    From openshop.io-android with MIT License 6 votes vote down vote up
/**
 * 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(Activity activity) {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
    if (resultCode != ConnectionResult.SUCCESS) {
        Timber.e("Google play services don't working.");
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(activity, resultCode, 9000)
                    .show();
        } else {
            Timber.e("GCM - This device is not supported.");
        }
        return false;
    }
    return true;
}
 
Example #15
Source File: OcrCaptureActivity.java    From Moneycim with MIT License 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #16
Source File: PermissionCheckGooglePlayServices.java    From magnet-client with Mozilla Public License 2.0 6 votes vote down vote up
public void check() {
    final GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    final int result = googleApiAvailability.isGooglePlayServicesAvailable(getActivity());

    if (result == ConnectionResult.SUCCESS) {
        done();
        return;
    }

    // IMPORTANT: We can't be sure that this code is
    // running on main-ui-thread, it depends where the
    // method was called from. For example React Native
    // responds to native bridge methods off main-ui-thread.
    // If a dialog is dispatched from a non-ui-thread thread,
    // when it is dismissed on main-ui-thread the app will crash.
    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            googleApiAvailability.showErrorDialogFragment(getActivity(), result, ID);
            done();
        }
    });
}
 
Example #17
Source File: MqttUartSettingsCodeReaderActivity.java    From Bluefruit_LE_Connect_Android with MIT License 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #18
Source File: GooglyEyesActivity.java    From android-vision with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #19
Source File: BarcodeCaptureActivity.java    From fuse-qreader with MIT License 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #20
Source File: CloudletDemoActivity.java    From faceswap with Apache License 2.0 6 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult result) {
    // Called whenever the API client fails to connect.
    Log.i(TAG, "GoogleApiClient connection failed: " + result.toString());
    Toast.makeText(this, "Failed to Connect to Google Drive. Trying to resolve...",
            Toast.LENGTH_SHORT).show();
    if (!result.hasResolution()) {
        // show the localized error dialog.
        GoogleApiAvailability.getInstance().getErrorDialog(this, result.getErrorCode(), 0).show();
        Log.i(TAG, "trying to resolve" + result.toString());
        pendingGDriveAction=-1;
        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 {
        result.startResolutionForResult(this, GDRIVE_RESOLVE_CONNECTION_REQUEST_CODE);
    } catch (IntentSender.SendIntentException e) {
        Log.e(TAG, "Exception while starting resolution activity", e);
    }
}
 
Example #21
Source File: FaceFilterActivity.java    From Android-face-filters with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #22
Source File: QrCodeCaptureActivity.java    From prebid-mobile-android with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #23
Source File: ChromeVersionInfo.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Returns info about the Google Play services setup for Chrome and the device.
 *
 * Contains the version number of the SDK Chrome was built with and the one for the installed
 * Play Services app. It also contains whether First Party APIs are available.
 */
@CalledByNative
public static String getGmsInfo() {
    Context context = ContextUtils.getApplicationContext();

    final long sdkVersion = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE;
    final long installedGmsVersion = getPlayServicesApkVersionNumber(context);

    final String accessType;
    UserRecoverableErrorHandler handler = new UserRecoverableErrorHandler.Silent();
    if (ExternalAuthUtils.getInstance().canUseFirstPartyGooglePlayServices(context, handler)) {
        accessType = "1p";
    } else if (ExternalAuthUtils.getInstance().canUseGooglePlayServices(context, handler)) {
        accessType = "3p";
    } else {
        accessType = "none";
    }

    return String.format(Locale.US,
            "SDK=%s; Installed=%s; Access=%s", sdkVersion, installedGmsVersion, accessType);
}
 
Example #24
Source File: Util.java    From Track-My-Location with GNU General Public License v3.0 6 votes vote down vote up
public static boolean checkGooglePlayServicesAvailability(Activity activity) {
    GoogleApiAvailability api = GoogleApiAvailability.getInstance();
    int resultCode = api.isGooglePlayServicesAvailable(activity);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (api.isUserResolvableError(resultCode)) {
            Dialog dialog = api.getErrorDialog(activity, resultCode, 1234);
            dialog.setCancelable(false);
            dialog.setOnCancelListener(dialogInterface -> activity.finish());
            dialog.show();
        } else {
            Toast.makeText(activity, "Device unsupported", Toast.LENGTH_LONG).show();
            activity.finish();
        }

        return false;
    }

    return true;
}
 
Example #25
Source File: BarcodeCaptureActivity.java    From trust-wallet-android-source with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #26
Source File: MainActivity.java    From apps-script-mobile-addons with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
 */
private boolean isGooglePlayServicesAvailable() {
    GoogleApiAvailability apiAvailability =
            GoogleApiAvailability.getInstance();
    final int connectionStatusCode =
            apiAvailability.isGooglePlayServicesAvailable(MainActivity.this);
    return connectionStatusCode == ConnectionResult.SUCCESS;
}
 
Example #27
Source File: GooglePaymentConfiguration.java    From braintree_android with MIT License 5 votes vote down vote up
/**
 * @return {@code true} if Google Payment is enabled and supported in the current environment,
 *         {@code false} otherwise. Note: this value only pertains to the Braintree configuration, to check if
 *         the user has Google Payment setup use
 *         {@link com.braintreepayments.api.GooglePayment#isReadyToPay(BraintreeFragment, BraintreeResponseListener)}
 */
public boolean isEnabled(Context context) {
    try {
        Class.forName(Wallet.class.getName());

        return mEnabled && GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) ==
                ConnectionResult.SUCCESS;
    } catch (ClassNotFoundException | NoClassDefFoundError e) {
        return false;
    }
}
 
Example #28
Source File: MapsActivity.java    From Krishi-Seva with MIT License 5 votes vote down vote up
private boolean CheckGooglePlayServices() {
    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int result = googleAPI.isGooglePlayServicesAvailable(this);
    if(result != ConnectionResult.SUCCESS) {
        if(googleAPI.isUserResolvableError(result)) {
            googleAPI.getErrorDialog(this, result,
                    0).show();
        }
        return false;
    }
    return true;
}
 
Example #29
Source File: Utils.java    From protrip with MIT License 5 votes vote down vote up
public static boolean isGooglePlayServicesAvailable(Activity activity) {
    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    int status = googleApiAvailability.isGooglePlayServicesAvailable(activity);
    if(status != ConnectionResult.SUCCESS) {
        if(googleApiAvailability.isUserResolvableError(status)) {
            //googleApiAvailability.getErrorDialog(activity, status, 2404).show();
        }
        return false;
    }
    return true;
}
 
Example #30
Source File: LocationGeofenceEditorActivity.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnected(Bundle connectionHint) {
    try {
        int version = GoogleApiAvailability.getInstance().getApkVersion(this.getApplicationContext());
        PPApplication.setCustomKey(PPApplication.CRASHLYTICS_LOG_GOOGLE_PLAY_SERVICES_VERSION, version);
    } catch (Exception e) {
        //PPApplication.recordException(e);
    }
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
    getLastLocation();
    startLocationUpdates();
}