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

项目:1946    文件:GcmPush.java   
private boolean checkPlayServices() 
{
       int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mContext);
       if (resultCode != ConnectionResult.SUCCESS) 
       {
           //if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) 
           //{
           //    GooglePlayServicesUtil.getErrorDialog(resultCode, mContext, PLAY_SERVICES_RESOLUTION_REQUEST).show();
           //} else {
           //    Log.i(TAG, "This device is not supported.");
           //}
        Log.i("yoyo", "!Google play not found on device");
           return false;
       }
       return true;
   }
项目:Pickr    文件:MainActivity.java   
private boolean checkPlayServices() {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(
                    resultCode, this, REQUEST_CODE_PLAY_SERVICES).show();
        } else {
            Dialog playServicesDialog = DialogFactory.createSimpleOkErrorDialog(
                    this,
                    getString(R.string.dialog_error_title),
                    getString(R.string.error_message_play_services)
            );
            playServicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    finish();
                }
            });
            playServicesDialog.show();
        }
        return false;
    }
    return true;
}
项目: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);
  }
}
项目:airgram    文件:ApplicationLoader.java   
private boolean checkPlayServices() {
    try {
        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        return resultCode == ConnectionResult.SUCCESS;
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    return true;

    /*if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
        } else {
            Log.i("tmessages", "This device is not supported.");
        }
        return false;
    }
    return true;*/
}
项目:feup-lpoo-armadillo    文件: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;
    }
}
项目:iosched-reader    文件:LoginAndAuthHelper.java   
private void showRecoveryDialog(int statusCode) {
    Activity activity = getActivity("showRecoveryDialog()");
    if (activity == null) {
        return;
    }

    if (sCanShowAuthUi) {
        sCanShowAuthUi = false;
        LOGD(TAG, "Showing recovery dialog for status code " + statusCode);
        final Dialog d = GooglePlayServicesUtil.getErrorDialog(
                statusCode, activity, REQUEST_RECOVER_FROM_PLAY_SERVICES_ERROR);
        d.show();
    } else {
        LOGD(TAG, "Not showing Play Services recovery dialog because sCanShowSignInUi==false.");
        reportAuthFailure();
    }
}
项目:iosched-reader    文件:PlayServicesUtils.java   
public static boolean checkGooglePlayServices(final Activity activity) {
    final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
    switch (googlePlayServicesCheck) {
        case ConnectionResult.SUCCESS:
            return true;
        case ConnectionResult.SERVICE_DISABLED:
        case ConnectionResult.SERVICE_INVALID:
        case ConnectionResult.SERVICE_MISSING:
        case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    activity.finish();
                }
            });
            dialog.show();
    }
    return false;
}
项目:PlusGram    文件:ApplicationLoader.java   
private boolean checkPlayServices() {
    try {
        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        return resultCode == ConnectionResult.SUCCESS;
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    return true;

    /*if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
        } else {
            Log.i("tmessages", "This device is not supported.");
        }
        return false;
    }
    return true;*/
}
项目:CustomAndroidOneSheeld    文件:GpsShield.java   
private boolean isGoogleplayServicesAvailableNoDialogs() {

        // Check that Google Play services is available
        int resultCode = GooglePlayServicesUtil
                .isGooglePlayServicesAvailable(getActivity()
                        .getApplicationContext());

        switch (resultCode) {
            case SUCCESS:
                return true;
            case SERVICE_DISABLED:
                return false;
            case SERVICE_MISSING:
                return false;
            case SERVICE_VERSION_UPDATE_REQUIRED:
                return false;
            case CANCELED:
                return false;

        }
        return false;

    }
项目:Pocket-Plays-for-Twitch    文件:Utils.java   
/**
 * A utility method to validate that the appropriate version of the Google Play Services is
 * available on the device. If not, it will open a dialog to address the issue. The dialog
 * displays a localized message about the error and upon user confirmation (by tapping on
 * dialog) will direct them to the Play Store if Google Play services is out of date or
 * missing, or to system settings if Google Play services is disabled on the device.
 */
public static boolean checkGooglePlayServices(final Activity activity) {
    final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(
            activity);
    switch (googlePlayServicesCheck) {
        case ConnectionResult.SUCCESS:
            return true;
        default:
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck,
                    activity, 0);
            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    activity.finish();
                }
            });
            dialog.show();
    }
    return false;
}
项目:treetracker-android    文件:MainActivity.java   
private boolean servicesConnected() {
    // Check that Google Play services is available
    int resultCode =
            GooglePlayServicesUtil.
                    isGooglePlayServicesAvailable(this);
    // If Google Play services is available
    if (ConnectionResult.SUCCESS == resultCode) {
        // In debug mode, log the status
        Log.d("LocationUpdates",
                "Google Play services is available.");
        // Continue
        return true;
        // Google Play services was not available for some reason
    } else {
        Log.e("LocationUpdates",
                "Google Play services is not available.");

    }
    return false;
}
项目: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();
    }
}
项目:Hexpert    文件:BaseGameUtils.java   
/**
 * Show a {@link android.app.Dialog} with the correct message for a connection error.
 *  @param activity the Activity in which the Dialog should be displayed.
 * @param requestCode the request code from onActivityResult.
 * @param actResp the response code from onActivityResult.
 * @param errorDescription the resource id of a String for a generic error message.
 */
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
    if (activity == null) {
        Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.app_misconfigured));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.sign_in_failed));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.license_failed));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, requestCode, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("BaseGamesUtils",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
            }
    }

    errorDialog.show();
}
项目:Android-nRF-Beacon-for-Eddystone    文件:AuthTaskUrlShortener.java   
private void handleAuthException(final Activity activity, final Exception e) {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (e instanceof GooglePlayServicesAvailabilityException) {
                // The Google Play services APK is old, disabled, or not present.
                // Show a dialog created by Google Play services that allows
                // the user to update the APK
                int statusCode = ((GooglePlayServicesAvailabilityException) e).getConnectionStatusCode();
                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
                        statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_URL_SHORTNER);
                dialog.show();
            } else if (e instanceof UserRecoverableAuthException) {
                // Unable to authenticate, such as when the user has not yet granted
                // the app access to the account, but the user can fix this.
                // Forward the user to an activity in Google Play services.
                Intent intent = ((UserRecoverableAuthException) e).getIntent();
                activity.startActivityForResult(
                        intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_URL_SHORTNER);

            }
        }
    });
}
项目:BeeksBeacon    文件:Utils.java   
public static void handleAuthException(final Activity activity, final Exception e) {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (e instanceof GooglePlayServicesAvailabilityException) {
                // The Google Play services APK is old, disabled, or not present.
                // Show a dialog created by Google Play services that allows
                // the user to update the APK
                int statusCode = ((GooglePlayServicesAvailabilityException)e).getConnectionStatusCode();
                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
                        statusCode, activity, Constants.REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR);
                dialog.show();
            }
            else if (e instanceof UserRecoverableAuthException) {
                // Unable to authenticate, such as when the user has not yet granted
                // the app access to the account, but the user can fix this.
                // Forward the user to an activity in Google Play services.
                Intent intent = ((UserRecoverableAuthException)e).getIntent();
                activity.startActivityForResult(
                        intent, Constants.REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR);
            }
        }
    });
}
项目:smconf-android    文件:LoginAndAuthHelper.java   
private void showRecoveryDialog(int statusCode) {
    Activity activity = getActivity("showRecoveryDialog()");
    if (activity == null) {
        return;
    }

    if (sCanShowAuthUi) {
        sCanShowAuthUi = false;
        LOGD(TAG, "Showing recovery dialog for status code " + statusCode);
        final Dialog d = GooglePlayServicesUtil.getErrorDialog(
                statusCode, activity, REQUEST_RECOVER_FROM_PLAY_SERVICES_ERROR);
        d.show();
    } else {
        LOGD(TAG, "Not showing Play Services recovery dialog because sCanShowSignInUi==false.");
        reportAuthFailure();
    }
}
项目:smconf-android    文件:PlayServicesUtils.java   
public static boolean checkGooglePlayServices(final Activity activity) {
    final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
    switch (googlePlayServicesCheck) {
        case ConnectionResult.SUCCESS:
            return true;
        case ConnectionResult.SERVICE_DISABLED:
        case ConnectionResult.SERVICE_INVALID:
        case ConnectionResult.SERVICE_MISSING:
        case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    activity.finish();
                }
            });
            dialog.show();
    }
    return false;
}
项目:aptoide-backup-apps    文件:MainActivity.java   
public void connectPlusClient() {
    int val = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (val == ConnectionResult.SUCCESS) {

        if(!mPlusClient.isConnected()) {
            if (mConnectionResult == null) {
                mPlusClient.connect();
                mConnectionProgressDialog.show();
            } else {
                try {
                    mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                } catch (IntentSender.SendIntentException e) {
                    // Try connecting again.
                    mConnectionResult = null;
                    mPlusClient.connect();
                }
            }
        }
    } else {
        Toast.makeText(this, getString(R.string.google_login_message_play_services_not_available), Toast.LENGTH_SHORT).show();
    }
}
项目:FindMeAHome    文件:LocationFragment.java   
private boolean checkPlayServices() {

        int resultCode = GooglePlayServicesUtil
                .isGooglePlayServicesAvailable(getActivity());
        if (resultCode != ConnectionResult.SUCCESS) {
            if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
                GooglePlayServicesUtil.getErrorDialog(resultCode, getActivity(),
                        PLAY_SERVICES_RESOLUTION_REQUEST).show();
            } else {
                Toast.makeText(getContext(),
                        getString(R.string.location_services_not_supported), Toast.LENGTH_LONG)
                        .show();
                getActivity().finish();
            }
            return false;
        }

        return true;
    }
项目:TextSecure    文件:GcmRefreshJob.java   
@Override
public void onRun() throws Exception {
  TextSecureAccountManager accountManager = TextSecureCommunicationFactory.createManager(context);
  String                   registrationId = TextSecurePreferences.getGcmRegistrationId(context);

  if (registrationId == null) {
    Log.w(TAG, "GCM registrationId expired, reregistering...");
    int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);

    if (result != ConnectionResult.SUCCESS) {
      notifyGcmFailure();
    } else {
      String gcmId = GoogleCloudMessaging.getInstance(context).register(REGISTRATION_ID);
      accountManager.setGcmId(Optional.of(gcmId));
      TextSecurePreferences.setGcmRegistrationId(context, gcmId);
    }
  }
}
项目:PhoneChat    文件:AsyncLicenseInfo.java   
@Override
protected AlertDialog.Builder doInBackground(Void... arg0) {
  String licenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(mActivity);

  AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivity);

  alertDialogBuilder
    .setMessage(licenseInfo)
    .setCancelable(false)
    .setPositiveButton("Close", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog,int id) {
        dialog.dismiss();
      }
    });

  return alertDialogBuilder;
}
项目:GoldenQuranAndroid    文件:LocationHelper.java   
private boolean checkPlayService(FragmentActivity fragmentActivity)
        throws IllegalArgumentException {
    int errorCode =
            GooglePlayServicesUtil.
                    isGooglePlayServicesAvailable(fragmentActivity);
    if (ConnectionResult.SUCCESS != errorCode) {
        if (GooglePlayServicesUtil.isUserRecoverableError(errorCode)) {
            Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
                    errorCode, fragmentActivity, REQUEST_CODE);

            ErrorDialogFragment errorFragment =
                    new ErrorDialogFragment();
            errorFragment.setDialog(errorDialog);
            errorFragment.show(fragmentActivity.getSupportFragmentManager(),
                    TAG);

            return false;
        } else {
            throw new IllegalArgumentException("Play Service not supported in this device");
        }
    } else {
        return true;
    }
}
项目:Tower-develop    文件:FlightDataFragment.java   
/**
 * Ensures that the device has the correct version of the Google Play
 * Services.
 *
 * @return true if the Google Play Services binary is valid
 */
private boolean isGooglePlayServicesValid(boolean showErrorDialog) {
    // Check for the google play services is available
    final int playStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getContext());
    final boolean isValid = playStatus == ConnectionResult.SUCCESS;

    if (!isValid && showErrorDialog) {
        final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(playStatus, getActivity(),
                GOOGLE_PLAY_SERVICES_REQUEST_CODE, new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        if (isAdded()) {
                            getActivity().finish();
                        }
                    }
                });

        if (errorDialog != null)
            errorDialog.show();
    }

    return isValid;
}
项目:mytracks    文件:TrackListActivity.java   
private void checkGooglePlayServices() {
  int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
  if (code != ConnectionResult.SUCCESS) {
    Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
        code, this, GOOGLE_PLAY_SERVICES_REQUEST_CODE, new DialogInterface.OnCancelListener() {

            @Override
          public void onCancel(DialogInterface dialogInterface) {
            finish();
          }
        });
    if (dialog != null) {
      dialog.show();
      return;
    }
  }
}
项目:SocialSignIn_Demo    文件:Utility.java   
public static boolean checkPlayServices(Context act) {

        Activity activity = (Activity)act;

        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
        if (resultCode != ConnectionResult.SUCCESS) {
            if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
                GooglePlayServicesUtil.getErrorDialog(resultCode, activity,
                        AppConstants.PLAY_SERVICES_RESOLUTION_REQUEST).show();
            } else {
                Log.i("checkPlayServices", "This device is not supported.");
                activity.finish();
            }
            return false;
        }
        return true;
    }
项目:2015-Google-I-O-app    文件:LoginAndAuthHelper.java   
private void showRecoveryDialog(int statusCode) {
    Activity activity = getActivity("showRecoveryDialog()");
    if (activity == null) {
        return;
    }

    if (sCanShowAuthUi) {
        sCanShowAuthUi = false;
        LOGD(TAG, "Showing recovery dialog for status code " + statusCode);
        final Dialog d = GooglePlayServicesUtil.getErrorDialog(
                statusCode, activity, REQUEST_RECOVER_FROM_PLAY_SERVICES_ERROR);
        d.show();
    } else {
        LOGD(TAG, "Not showing Play Services recovery dialog because sCanShowSignInUi==false.");
        reportAuthFailure();
    }
}
项目:2015-Google-I-O-app    文件:PlayServicesUtils.java   
public static boolean checkGooglePlayServices(final Activity activity) {
    final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
    switch (googlePlayServicesCheck) {
        case ConnectionResult.SUCCESS:
            return true;
        case ConnectionResult.SERVICE_DISABLED:
        case ConnectionResult.SERVICE_INVALID:
        case ConnectionResult.SERVICE_MISSING:
        case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    activity.finish();
                }
            });
            dialog.show();
    }
    return false;
}
项目:Flock    文件:MainActivity.java   
private boolean checkGooglePlayServicesAvailable()
{
    final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
    if (status == ConnectionResult.SUCCESS)
    {
        return true;
    }

    Log.e("MAIN ACTIVITY", "Google Play Services not available: " + GooglePlayServicesUtil.getErrorString(status));

    if (GooglePlayServicesUtil.isUserRecoverableError(status))
    {
        final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(status, this, 1);
        if (errorDialog != null)
        {
            errorDialog.show();
        }
    }

    return false;
}
项目:Location    文件:AddActivity.java   
/**
 * Method to verify google play services on the device
 * */
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 {
            Toast.makeText(getApplicationContext(),
                    "This device is not supported.", Toast.LENGTH_LONG)
                    .show();
            finish();
        }
        return false;
    }
    return true;
}
项目:CycleFrankfurtAndroid    文件:RecordingActivity.java   
public void startUpdates() {
    // If a request is not already underway

    mRequestType = REQUEST_TYPE.START;
    if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) != ConnectionResult.SUCCESS) {
        return;
    }

    if (!mInProgress) {
        mInProgress = true; // Indicate that a request is in progress
        mActivityRecognitionClient.connect(); // Request a connection to Location Services
    } else {
        /*
         * A request is already underway. You can handle
         * this situation by disconnecting the client,
         * re-setting the flag, and then re-trying the
         * request.
         */
        // TODO:
    }
}
项目:CycleFrankfurtAndroid    文件:MainInput.java   
@Override
public void onResume() {
    super.onResume();

    // Check that Google Play services is available
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (ConnectionResult.SUCCESS == resultCode) {
        Log.d("Location Updates", "Google Play services is available.");
        return;
    // Google Play services was not available for some reason
    } else {
        // Get the error dialog from Google Play services
        Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, CONNECTION_FAILURE_RESOLUTION_REQUEST);
        // If Google Play services can provide an error dialog
        if (errorDialog != null) {
            ErrorDialogFragment errorFragment = new ErrorDialogFragment();
            errorFragment.setDialog(errorDialog);
            errorFragment.show(getSupportFragmentManager(), "Location Updates");
        }
    }
}
项目:Runch    文件:MainActivity.java   
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

    if (mResolvingError) {
        // Already attempting to resolve an error.
        return;
    } else if (connectionResult.hasResolution()) {
        try {
            mResolvingError = true;
            connectionResult.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
        } catch (IntentSender.SendIntentException e) {
            // There was an error with the resolution intent. Try again.
            googleApiClient.connect();
        }
    } else {
        // Show dialog using GooglePlayServicesUtil.getErrorDialog()
        GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(),this,GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE).show();
        mResolvingError = true;
    }

    Log.i(TAG, "Location services connection failed with code " + connectionResult.getErrorCode());

}
项目:Runch    文件:RestaurantInfoActivity.java   
@Override
protected void onResume() {
    super.onResume();

    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    if (resultCode == ConnectionResult.SUCCESS) {
        mRecyclerView.setAdapter(mListAdapter);
    } else {
        GooglePlayServicesUtil.getErrorDialog(resultCode, this, 1).show();
    }

    if (mListAdapter != null) {
        for (MapView m : mListAdapter.getMapViews()) {
            m.onResume();
        }
    }
}
项目:WhosUp    文件:MainActivity.java   
/**
 * Method to verify google play services on the device
 * */
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 {
            Toast.makeText(getApplicationContext(),
                    "This device is not supported.", Toast.LENGTH_LONG)
                    .show();
            finish();
        }
        return false;
    }
    return true;
}
项目:QuietPlaces    文件:MainActivity.java   
/**
 * Called if the device does not have Google Play Services installed.
 */
void showGooglePlayServicesAvailabilityErrorDialog(final int connectionStatusCode) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            try {
                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
                        connectionStatusCode, MainActivity.this, REQUEST_GOOGLE_PLAY_SERVICES);
                dialog.show();
            } catch (Exception e) {
                Log.e(TAG, "Unable to obtain Google Play!.", e);
            }

        }
    });
}
项目:FMTech    文件:GoogleAuthUtil.java   
public static PendingIntent getRecoveryIfSuggested$12f08959(Context paramContext, String paramString)
  throws IOException, UserRecoverableAuthException, GoogleAuthException
{
  zzx.zzcy("Calling this from your main thread can lead to deadlock");
  try
  {
    GooglePlayServicesUtil.zzae(paramContext.getApplicationContext());
    final Bundle localBundle = new Bundle();
    localBundle.putString(KEY_ANDROID_PACKAGE_NAME, paramContext.getPackageName());
    zza local3 = new zza() {};
    RecoveryDecision localRecoveryDecision = (RecoveryDecision)zza(paramContext, zzVm, local3);
    if ((localRecoveryDecision.showRecoveryInterstitial) && (localRecoveryDecision.isRecoveryInterstitialAllowed)) {
      return localRecoveryDecision.recoveryIntent;
    }
  }
  catch (GooglePlayServicesRepairableException localGooglePlayServicesRepairableException)
  {
    throw new GooglePlayServicesAvailabilityException(localGooglePlayServicesRepairableException.zzVA, localGooglePlayServicesRepairableException.getMessage(), new Intent(localGooglePlayServicesRepairableException.mIntent));
  }
  catch (GooglePlayServicesNotAvailableException localGooglePlayServicesNotAvailableException)
  {
    throw new GoogleAuthException(localGooglePlayServicesNotAvailableException.getMessage());
  }
  return null;
}
项目:FMTech    文件:Flags.java   
public static void initialize(Context paramContext)
{
  zzja.zzb(new Callable()
  {
    private Void zzdv()
    {
      zzf localzzf = zzp.zzbR();
      Context localContext1 = this.zzsR;
      Context localContext2;
      synchronized (localzzf.zzqp)
      {
        if (localzzf.zzqM) {
          break label74;
        }
        localContext2 = GooglePlayServicesUtil.getRemoteContext(localContext1);
        if (localContext2 != null) {}
      }
      zzp.zzbP();
      localzzf.zzvG = localContext2.getSharedPreferences("google_ads_flags", 1);
      localzzf.zzqM = true;
      label74:
      return null;
    }
  });
}
项目:android-wear-voice-message    文件:WearActivity.java   
@Override
protected void onResume() {
    super.onResume();

    // Check is Google Play Services available
    int connectionResult = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());

    if (connectionResult != ConnectionResult.SUCCESS) {
        // Google Play Services is NOT available. Show appropriate error dialog
        GooglePlayServicesUtil.showErrorDialogFragment(connectionResult, this, 0, new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
    } else {
        apiClient.connect();
    }
}
项目:WhosUp    文件:RegisterInGCM.java   
private boolean isGoogelPlayInstalled() {
    int resultCode = GooglePlayServicesUtil
            .isGooglePlayServicesAvailable(context);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(resultCode, mRegisterActivity,
                    ACTION_PLAY_SERVICES_DIALOG).show();
        } else {
            Toast.makeText(context,
                    "Google Play Service is not installed. Cannot receive notifications",
                    Toast.LENGTH_SHORT).show();

        }
        return false;
    }
    return true;

}
项目:Hermes    文件:Hermes.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.
 */
public static boolean checkPlayServices(Context context) {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            Log.d(TAG, "Google Play Services is not available, but the issue is User Recoverable");
            if (context instanceof Activity) {
                GooglePlayServicesUtil.getErrorDialog(resultCode, (Activity) context, PLAY_SERVICES_RESOLUTION_REQUEST).show();
            }
        } else {
            /**
             * TODO: Handle all issue related to non User recoverable error
             */
            Log.e(TAG, "Non user recoverable error while checking for Play Services");
        }
        return false;
    }
    return true;
}