Java 类com.google.android.gms.common.ConnectionResult 实例源码

项目:Toodoo    文件:ToodooCamera.java   
/**
 * 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;
        }
    }
}
项目:MuslimMateAndroid    文件:MosquesActivity.java   
/**
 * Start to attach google location services
 */
public void startFusedLocation() {
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API)
                .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                    @Override
                    public void onConnectionSuspended(int cause) {
                    }

                    @Override
                    public void onConnected(Bundle connectionHint) {
                    }
                }).addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {

                    @Override
                    public void onConnectionFailed(ConnectionResult result) {

                    }
                }).build();
        mGoogleApiClient.connect();
    } else {
        mGoogleApiClient.connect();
    }
}
项目:Pocket-Plays-for-Twitch    文件:BaseCastManager.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    LOGD(TAG, "onConnectionFailed() reached, error code: " + result.getErrorCode()
            + ", reason: " + result.toString());
    disconnectDevice(mDestroyOnDisconnect, false /* clearPersistentConnectionData */,
            false /* setDefaultRoute */);
    mConnectionSuspended = false;
    if (mMediaRouter != null) {
        mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
    }

    for (BaseCastConsumer consumer : mBaseCastConsumers) {
        consumer.onConnectionFailed(result);
    }

    PendingIntent pendingIntent = result.getResolution();
    if (pendingIntent != null) {
        try {
            pendingIntent.send();
        } catch (PendingIntent.CanceledException e) {
            LOGE(TAG, "Failed to show recovery from the recoverable error", e);
        }
    }
}
项目:AndiCar    文件:SecureBackupJob.java   
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    try {
        String message = getString(R.string.error_056);
        if (connectionResult.getErrorMessage() != null && connectionResult.getErrorMessage().length() > 0)
            message = connectionResult.getErrorMessage();
        else if (connectionResult.getErrorCode() == ConnectionResult.SIGN_IN_REQUIRED) {
            message = getString(R.string.error_121);
        }
        else if (connectionResult.getErrorCode() == ConnectionResult.SIGN_IN_FAILED) {
            message = getString(R.string.error_122);
        }

        AndiCarNotification.showGeneralNotification(this, AndiCarNotification.NOTIFICATION_TYPE_NOT_REPORTABLE_ERROR,
                (int) System.currentTimeMillis(), getString(R.string.pref_category_secure_backup), message, null, null);


        if (debugLogFileWriter != null) {
            debugLogFileWriter.appendnl("Connection failed: ").append(message);
            debugLogFileWriter.flush();
        }
    } catch (IOException e2) {
        e2.printStackTrace();
    }
}
项目:SpaceRace    文件:AbsRoomActivity.java   
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Log.d("INTRO", "onConnectionFailed:" + connectionResult);

    if (mResolvingConnectionFailure) {
        Log.d("CONNECTION", "onConnectionFailed() ignoring connection failure; already resolving.");
        return;
    }

    if (mSignInClicked || mAutoStartSignInFlow) {
        mAutoStartSignInFlow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = BaseGameUtils.resolveConnectionFailure(this,
                SpaceRace.getgAPIClient(),
                connectionResult, RC_SIGN_IN, getString(R.string.signin_other_error));
    }
}
项目:MuslimMateAndroid    文件:FusedLocationService.java   
/**
 * Start to attach google location services
 */
public void startFusedLocation() {
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(context).addApi(LocationServices.API)
                .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                    @Override
                    public void onConnectionSuspended(int cause) {
                    }

                    @Override
                    public void onConnected(Bundle connectionHint) {
                    }
                }).addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {

                    @Override
                    public void onConnectionFailed(ConnectionResult result) {

                    }
                }).build();
        mGoogleApiClient.connect();
    } else {
        mGoogleApiClient.connect();
    }
}
项目:DeepImagePreview-Project    文件:ScanFragment.java   
/**
 * 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;
        }
    }
}
项目:JobSchedulerCompat    文件:JobSchedulerTest.java   
@Test
@Config(sdk = Build.VERSION_CODES.KITKAT, shadows = {ShadowGoogleApiAvailability.class})
public void testSchedulerInApi19() {
    JobInfo api21Job = JobCreator.create(context, 0).setRequiresCharging(true).build();
    JobInfo api24Job = JobCreator.create(context, 3).setPeriodic(15 * 60 * 1000L, 5 * 60 * 1000L).build();
    JobInfo api26Job = JobCreator.create(context, 1).setRequiresBatteryNotLow(true).build();

    ShadowGoogleApiAvailability.setIsGooglePlayServicesAvailable(ConnectionResult.SERVICE_MISSING);

    assertThat(jobScheduler.getSchedulerForJob(context, api21Job), instanceOf(AlarmScheduler.class));
    assertThat(jobScheduler.getSchedulerForJob(context, api24Job), instanceOf(AlarmScheduler.class));
    assertThat(jobScheduler.getSchedulerForJob(context, api26Job), instanceOf(AlarmScheduler.class));

    ShadowGoogleApiAvailability.setIsGooglePlayServicesAvailable(ConnectionResult.SUCCESS);

    assertThat(jobScheduler.getSchedulerForJob(context, api21Job), instanceOf(GcmScheduler.class));
    assertThat(jobScheduler.getSchedulerForJob(context, api24Job), instanceOf(GcmScheduler.class));
    assertThat(jobScheduler.getSchedulerForJob(context, api26Job), instanceOf(AlarmScheduler.class));
}
项目:dbsync    文件:TestGDriveActivity.java   
@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();
    }
}
项目:AndroidProgramming3e    文件:LocatrActivity.java   
@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();
    }
}
项目:twilio-voice-phonegap-plugin    文件:TwilioVoicePlugin.java   
/**
 * 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;
}
项目:Excuser    文件:SplashActivity.java   
@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;
}
项目:Moneycim    文件:OcrCaptureActivity.java   
/**
 * 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;
        }
    }
}
项目:Programmers    文件:GoogleServices.java   
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;
}
项目:piast-trail    文件:PlaceListFragment.java   
@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();
    }
}
项目:PeSanKita-android    文件:GcmRefreshJob.java   
@Override
public void onRun() throws Exception {
  if (TextSecurePreferences.isGcmDisabled(context)) return;

  Log.w(TAG, "Reregistering GCM...");
  int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);

  if (result != ConnectionResult.SUCCESS) {
    notifyGcmFailure();
  } else {
    String gcmId = GoogleCloudMessaging.getInstance(context).register(REGISTRATION_ID);
    textSecureAccountManager.setGcmId(Optional.of(gcmId));

    TextSecurePreferences.setGcmRegistrationId(context, gcmId);
    TextSecurePreferences.setWebsocketRegistered(context, true);
  }
}
项目:OfflineSampleApp    文件:JobManagerFactory.java   
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());
}
项目:AndroidProgramming3e    文件:MockWalkerActivity.java   
@Override
protected void onResume() {
    super.onResume();

    int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    if (errorCode != ConnectionResult.SUCCESS) {
        Dialog errorDialog = GooglePlayServicesUtil
                .getErrorDialog(errorCode, this, REQUEST_ERROR,
                        new DialogInterface.OnCancelListener() {

                            @Override
                            public void onCancel(DialogInterface dialog) {
                                // Leave if services are unavailable.
                                finish();
                            }
                        });

        errorDialog.show();
    }
}
项目:chromium-for-android-56-debug-video    文件:PrecacheTaskScheduler.java   
boolean canScheduleTasks(Context context) {
    if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)
            != ConnectionResult.SUCCESS) {
        return false;
    }
    return true;
}
项目:MedicalMe    文件:MapsActivity.java   
public boolean googleplayservice() {
    GoogleApiAvailability api = GoogleApiAvailability.getInstance();
    int isAvaible = api.isGooglePlayServicesAvailable(this);
    if (isAvaible == ConnectionResult.SUCCESS) {
        return true;
    } else if (api.isUserResolvableError(isAvaible)) {
        Dialog dialog = api.getErrorDialog(this, isAvaible, 0);
        dialog.show();
    } else {
        Toast.makeText(this, "Can't Connect to play services", Toast.LENGTH_LONG).show();
    }
    return false;
}
项目:Asteroid    文件:BaseGameUtils.java   
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity             the Activity trying to resolve the connection failure.
 * @param client               the GoogleAPIClient instance of the Activity.
 * @param result               the ConnectionResult received by the Activity.
 * @param requestCode          a request code which the calling Activity can use to identify the result
 *                             of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               int fallbackErrorMessage) {

    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity, requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, activity.getString(fallbackErrorMessage));
        }
        return false;
    }
}
项目:Hexpert    文件:BaseGameUtils.java   
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity the Activity trying to resolve the connection failure.
 * @param client the GoogleAPIClient instance of the Activity.
 * @param result the ConnectionResult received by the Activity.
 * @param requestCode a request code which the calling Activity can use to identify the result
 *                    of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               int fallbackErrorMessage) {

    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity, requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, activity.getString(fallbackErrorMessage));
        }
        return false;
    }
}
项目:friendlychat-android    文件:SignInActivity.java   
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    // An unresolvable error has occurred and Google APIs (including Sign-In) will not
    // be available.
    Log.d(TAG, "onConnectionFailed:" + connectionResult);
    Toast.makeText(this, "Google Play Services error.", Toast.LENGTH_SHORT).show();
}
项目:Wallpapers-Android-Clean-Architecture    文件:DataModule.java   
@Singleton @Provides IRemoteConfig provideRemoteConfig(MainApplication application,
        IAnalytics analytics) {
    int playServicesStatus =
            GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(application);
    if (playServicesStatus == ConnectionResult.SUCCESS) {
        return new RemoteConfig(BuildConfig.DEBUG, analytics);
    } else {
        return key -> IRemoteConfig.ExperimentVariant.NONE;
    }
}
项目:MuslimMateAndroid    文件:FusedLocationService.java   
/**
 * Function to check google play services
 *
 * @return Found or not
 */
private boolean checkPlayServices() {
    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int result = googleAPI.isGooglePlayServicesAvailable(context);
    if (result != ConnectionResult.SUCCESS) {
        if (googleAPI.isUserResolvableError(result)) {
            googleAPI.getErrorDialog((Activity) context, result,
                    1).show();
        }

        return false;
    }

    return true;
}
项目:zabbkit-android    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    loadingLayout = (RelativeLayout) findViewById(R.id.alert_layout);

    WearableListView listView =
            (WearableListView) findViewById(R.id.triggers_list);

    // Assign an adapter to the list
    eventsAdapter = new EventsAdapter(this, triggersDataSet);
    listView.setAdapter(eventsAdapter);

    googleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(Bundle connectionHint) {
                    Log.d("Error!", "onConnected: " + connectionHint);
                    sendTriggersRequest();
                }

                @Override
                public void onConnectionSuspended(int cause) {
                    Log.d("Error!", "onConnectionSuspended: " + cause);
                }
            })
            .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult result) {
                    Log.d("Error!", "onConnectionFailed: " + result);
                }
            })
            .addApi(Wearable.API)
            .build();
    // Set a click listener
    //listView.setClickListener(this);

}
项目:VEHICLE-APP    文件:MapsActivity.java   
private boolean isGooglePlayServicesAvailable() {
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if (ConnectionResult.SUCCESS == status) {
                return true;
        } else {
                GooglePlayServicesUtil.getErrorDialog(status, this, 0).show();
                return false;
        }
}
项目:divertsy-client    文件:SyncToDriveService.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    Log.i(TAG, "GoogleApiClient connection failed: " + result.toString());

    if (result.getErrorCode() == SERVICE_MISSING){
        showMessage("Google Drive API not Found on this Device");
        Log.e(TAG, "Google Drive SERVICE_MISSING");
    }

    if (result.getErrorCode() == SERVICE_VERSION_UPDATE_REQUIRED){
        showMessage("Google Play Services update required. Please update in Google Play store.");
        Log.e(TAG, "Google Play Services update required");
        mGoogleApiClient.getContext().startActivity(new Intent(mGoogleApiClient.getContext(), MainActivity.class)
                .putExtra("PlayServicesUpdate", true).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
    }

    PendingIntent pI = result.getResolution();
    if (pI != null) {
        Log.v(TAG, "PendingIntent: " + pI.getIntentSender().toString());
        mGoogleApiClient.getContext().startActivity(new Intent(mGoogleApiClient.getContext(), MainActivity.class)
                .putExtra("resolution", pI).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
    } else {
        Log.e(TAG, "Pending Intent resolution was Null");
    }

    // If we don't stop this service, we tend to have an invalid API client
    // when we call the first Create new Drive file command
    stopSelf(mStartID);
}
项目:RxSocialAuth    文件:RxGoogleAuthFragment.java   
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    if(mAuthAction == AuthAction.SIGN_IN || mAuthAction == AuthAction.SILENT_SIGN_IN) {
        mGoogleApiClient.disconnect();
        mAccountSubject.onError(new Throwable(connectionResult.toString()));
    }
    else {
        mGoogleApiClient.disconnect();
        mStatusSubject.onError(new Throwable(connectionResult.toString()));
    }
}
项目:chromium-for-android-56-debug-video    文件:AccountSigninView.java   
private boolean checkGooglePlayServicesAvailable() {
    ExternalAuthUtils extAuthUtils = ExternalAuthUtils.getInstance();
    if (mGooglePlayServicesUpdateErrorHandler == null) {
        mGooglePlayServicesUpdateErrorHandler = new UserRecoverableErrorHandler.ModalDialog(
                mDelegate.getActivity());
    }
    int resultCode = extAuthUtils.canUseGooglePlayServicesResultCode(
            getContext(), mGooglePlayServicesUpdateErrorHandler);
    if (extAuthUtils.isGooglePlayServicesUpdateRequiredError(resultCode)) {
        mIsGooglePlayServicesOutOfDate = true;
    }
    return resultCode == ConnectionResult.SUCCESS;
}
项目:Appmatic-Android    文件:ContactFragment.java   
private boolean checkPlayServices() {
    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int result = googleAPI.isGooglePlayServicesAvailable(getActivity());

    if (result != ConnectionResult.SUCCESS) {
        if (googleAPI.isUserResolvableError(result))
            googleAPI.getErrorDialog(getActivity(), result, 0).show();
        return false;
    }
    return true;
}
项目:Shush    文件:MainActivity.java   
/**
 * Called when the google API client failed to connect to the PlayServices.
 * @param connectionResult A coonectionResult that can be used to solve the error.
 */
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Log.i(LOG_TAG,"API Connection client suspended.");
    Toast.makeText(this, "onConectionFailed", Toast.LENGTH_SHORT).show();

}
项目:gdx-gamesvcs    文件:BaseGameUtils.java   
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity the Activity trying to resolve the connection failure.
 * @param client the GoogleAPIClient instance of the Activity.
 * @param result the ConnectionResult received by the Activity.
 * @param requestCode a request code which the calling Activity can use to identify the result
 *                    of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               String fallbackErrorMessage) {

    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity, requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, fallbackErrorMessage);
        }
        return false;
    }
}
项目:PrivacyStreams    文件:DeviceUtils.java   
/**
 * 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;
}
项目:penguins-in-space    文件:GameHelperUtils.java   
static String errorCodeToString(int errorCode) {
    switch (errorCode) {
        case ConnectionResult.DEVELOPER_ERROR:
            return "DEVELOPER_ERROR(" + errorCode + ")";
        case ConnectionResult.INTERNAL_ERROR:
            return "INTERNAL_ERROR(" + errorCode + ")";
        case ConnectionResult.INVALID_ACCOUNT:
            return "INVALID_ACCOUNT(" + errorCode + ")";
        case ConnectionResult.LICENSE_CHECK_FAILED:
            return "LICENSE_CHECK_FAILED(" + errorCode + ")";
        case ConnectionResult.NETWORK_ERROR:
            return "NETWORK_ERROR(" + errorCode + ")";
        case ConnectionResult.RESOLUTION_REQUIRED:
            return "RESOLUTION_REQUIRED(" + errorCode + ")";
        case ConnectionResult.SERVICE_DISABLED:
            return "SERVICE_DISABLED(" + errorCode + ")";
        case ConnectionResult.SERVICE_INVALID:
            return "SERVICE_INVALID(" + errorCode + ")";
        case ConnectionResult.SERVICE_MISSING:
            return "SERVICE_MISSING(" + errorCode + ")";
        case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
            return "SERVICE_VERSION_UPDATE_REQUIRED(" + errorCode + ")";
        case ConnectionResult.SIGN_IN_REQUIRED:
            return "SIGN_IN_REQUIRED(" + errorCode + ")";
        case ConnectionResult.SUCCESS:
            return "SUCCESS(" + errorCode + ")";
        default:
            return "Unknown error code " + errorCode;
    }
}
项目:TripleTap    文件:BaseGameUtils.java   
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity             the Activity trying to resolve the connection failure.
 * @param client               the GoogleAPIClient instance of the Activity.
 * @param result               the ConnectionResult received by the Activity.
 * @param requestCode          a request code which the calling Activity can use to identify the result
 *                             of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               String fallbackErrorMessage) {

    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity, requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, fallbackErrorMessage);
        }
        return false;
    }
}
项目:Casty    文件:Casty.java   
/**
 * Creates the Casty object.
 *
 * @param activity {@link Activity} in which Casty object is created
 * @return the Casty object
 */
public static Casty create(@NonNull Activity activity) {
    int playServicesState = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity);
    if (playServicesState == ConnectionResult.SUCCESS) {
        return new Casty(activity);
    } else {
        Log.w(Casty.TAG, "Google Play services not found on a device, Casty won't work.");
        return new CastyNoOp();
    }
}
项目:Android_watch_magpie    文件:LoginActivity.java   
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 {
            Log.i(TAG, "This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}
项目:homeworkManager-android    文件:AddHomeworkPresenter.java   
/**
 * 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(context);
    return connectionStatusCode == ConnectionResult.SUCCESS;
}
项目:penguins-in-space    文件:BaseGameUtils.java   
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity             the Activity trying to resolve the connection failure.
 * @param client               the GoogleAPIClient instance of the Activity.
 * @param result               the ConnectionResult received by the Activity.
 * @param requestCode          a request code which the calling Activity can use to identify the result
 *                             of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               String fallbackErrorMessage) {

    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity, requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, fallbackErrorMessage);
        }
        return false;
    }
}