/**
   * @param activity The context (normally the UI context)
   * @return boolean True if successfully connected
   */
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private final boolean servicesConnected(Activity activity) {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
    if (resultCode != ConnectionResult.SUCCESS) {
      Dialog errorDialog =
          GooglePlayServicesUtil.getErrorDialog(
              resultCode, activity, CONNECTION_FAILURE_RESOLUTION_REQUEST);
      // Can Google Play service provide an error dialog
      if (errorDialog != null) {

        PackageInfo pInfo;
        try {
          pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
          // only version 11 and above support ErrorDialogFragment
          if (pInfo.versionCode >= Build.VERSION_CODES.HONEYCOMB) {
            ErrorDialogFragment errorFragment = new ErrorDialogFragment();
            // Set the dialog in the DialogFragment
            errorFragment.setDialog(errorDialog);
            // Show the error dialog in the DialogFragment
            errorFragment.show(activity.getFragmentManager(), serviceDescription_);
          }
        } catch (NameNotFoundException e) {
          Log.w(serviceDescription_, "Unable to determine version", e);
        }
      } else {
        Log.e(serviceDescription_, "Failed to get Map Service" + resultCode);
      }
      return false;
    } else {
      Log.d(serviceDescription_, "Google Play services is available.");
      return true;
    }
  }
Esempio n. 2
0
  /**
   * 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;
  }
  public void connect() {
    int playServiceAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    switch (playServiceAvailable) {
      case ConnectionResult.SUCCESS:
        client =
            new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();

        if (!isResolvingError) client.connect();

        break;

      case ConnectionResult.SERVICE_MISSING:
      case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
      case ConnectionResult.SERVICE_DISABLED:
        System.out.println("-------------- FAILURE --------------");
        GooglePlayServicesUtil.getErrorDialog(
            playServiceAvailable, this, DH_REQUEST_CODE_ERROR_DIALOG);
        break;
    }
  }
Esempio n. 4
0
 @Override
 public void onConnectionFailed(ConnectionResult connectionResult) {
   if (statusesToHandle.contains(connectionResult.getErrorCode())) {
     GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
   }
   if (!gPlusSignInInProgress) {
     if (gPlusSignInClicked && connectionResult.hasResolution()) {
       try {
         gPlusSignInInProgress = true;
         startIntentSenderForResult(
             connectionResult.getResolution().getIntentSender(), 0, null, 0, 0, 0);
       } catch (IntentSender.SendIntentException e) {
         e.printStackTrace();
         gPlusSignInInProgress = false;
         googleApiClient.connect();
       }
     } else {
       googleApiClient.disconnect();
       if (progressDialog != null) {
         progressDialog.dismiss();
       }
     }
   } else {
     googleApiClient.disconnect();
     if (progressDialog != null) {
       progressDialog.dismiss();
     }
   }
 }
Esempio n. 5
0
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   // Get the error code and retrieve the appropriate dialog
   int errorCode = this.getArguments().getInt(DIALOG_ERROR);
   return GooglePlayServicesUtil.getErrorDialog(
       errorCode, this.getActivity(), REQUEST_CODE_RESOLUTION);
 }
Esempio n. 6
0
  @Override
  public void onConnectionFailed(ConnectionResult result) {
    //        Toast.makeText(this, "onConnection Failed", Toast.LENGTH_SHORT).show();
    if (!result.hasResolution()) {
      GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
      return;
    }

    if (null != dialog) {
      if (dialog.isShowing()) {
        dialog.dismiss();
      }
    }

    if (!mIntentInProgress) {
      // Store the ConnectionResult for later usage
      mConnectionResult = result;

      if (mSignInClicked) {
        // The user has already clicked 'sign-in' so we attempt to
        // resolve all
        // errors until the user is signed in, or they cancel.
        resolveSignInError();
      }
    }
  }
  private boolean isGooglePlayServicesAvailable() {
    // 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("Location Updates", "Google Play services is available.");
      return true;
    } 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) {
        // Create a new DialogFragment for the error dialog
        ErrorDialogFragment errorFragment = new ErrorDialogFragment();
        errorFragment.setDialog(errorDialog);
        errorFragment.show(getSupportFragmentManager(), "Location Updates");
      }

      return false;
    }
  }
Esempio n. 8
0
  /**
   * To check if Google Play Services is installed and up to date ! Propose to update if needed
   *
   * @return boolean if is really connected
   */
  private boolean servicesConnected() {
    // Check that Google Play services is available
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(MainActivity.baseContext);
    // If Google Play services is available
    if (ConnectionResult.SUCCESS == resultCode) {
      // In debug mode, log the status
      Log.d("Location Updates", "Google Play services is available.");
      // Continue
      return true;
      // Google Play services was not available for some reason
    } else {
      // Get the error code
      // 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) {
        // Create a new DialogFragment for the error dialog
        ErrorDialogFragment errorFragment = new ErrorDialogFragment();
        // Set the dialog in the DialogFragment
        errorFragment.setDialog(errorDialog);
        // Show the error dialog in the DialogFragment
        errorFragment.show(getFragmentManager(), "Location Updates");
      }
    }
    return false;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //	Toast.makeText(this, "onCreate ", Toast.LENGTH_SHORT).show();
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_map);
    // Show the Up button in the action bar.
    setupActionBar();

    // Getting Google Play availability status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    // Showing status
    if (status != ConnectionResult.SUCCESS) { // Google Play Services are
      // not available

      int requestCode = 10;
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
      dialog.show();

    } else { // Google Play Services are available
      // Getting reference to the SupportMapFragment of activity_main.xml
      SupportMapFragment fm =
          (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

      // Getting GoogleMap object from the fragment
      googleMap = fm.getMap();

      // Enabling MyLocation Layer of Google Map
      googleMap.setMyLocationEnabled(true);

      googleMap.setOnInfoWindowClickListener(this);
    }
  }
Esempio n. 10
0
 private boolean isGooglePlayServicesAvailable() {
   int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (ConnectionResult.SUCCESS == status) {
     return true;
   } else {
     GooglePlayServicesUtil.getErrorDialog(status, this, 0).show();
     return false;
   }
 }
    @Override
    protected HashMap<String, String> doInBackground(Long... values) {

      mResults = new HashMap<String, String>();

      String selection = InstanceColumns._ID + "=?";
      String[] selectionArgs = new String[(values == null) ? 0 : values.length];
      if (values != null) {
        for (int i = 0; i < values.length; i++) {
          if (i != values.length - 1) {
            selection += " or " + InstanceColumns._ID + "=?";
          }
          selectionArgs[i] = values[i].toString();
        }
      }

      String token = null;
      try {
        token = authenticate(GoogleMapsEngineUploaderActivity.this, mGoogleUserName);
      } catch (IOException e) {
        // network or server error, the call is expected to succeed if
        // you try again later. Don't attempt to call again immediately
        // - the request is likely to fail, you'll hit quotas or
        // back-off.
        e.printStackTrace();
        mResults.put("0", oauth_fail + e.getMessage());
        return mResults;
      } catch (GooglePlayServicesAvailabilityException playEx) {
        Dialog alert =
            GooglePlayServicesUtil.getErrorDialog(
                playEx.getConnectionStatusCode(),
                GoogleMapsEngineUploaderActivity.this,
                PLAYSTORE_REQUEST_CODE);
        alert.show();
        return null;
      } catch (UserRecoverableAuthException e) {
        GoogleMapsEngineUploaderActivity.this.startActivityForResult(
            e.getIntent(), USER_RECOVERABLE_REQUEST_CODE);
        e.printStackTrace();
        return null;
      } catch (GoogleAuthException e) {
        // Failure. The call is not expected to ever succeed so it
        // should not be retried.
        e.printStackTrace();
        mResults.put("0", oauth_fail + e.getMessage());
        return mResults;
      }

      if (token == null) {
        // if token is null,
        return null;
      }

      uploadInstances(selection, selectionArgs, token);
      return mResults;
    }
Esempio n. 12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_layout);

    bar = (ProgressBar) findViewById(R.id.progressBar);

    // Getting Google Play availability status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    // Showing status
    if (status != ConnectionResult.SUCCESS) { // Google Play Services are not available

      int requestCode = 10;
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
      dialog.show();

    } else { // Google Play Services are available

      mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
      // Getting GoogleMap object from the fragment
      mMap = mapFragment.getMap();

      // Enabling MyLocation Layer of Google Map
      mMap.setMyLocationEnabled(true);

      // Getting LocationManager object from System Service LOCATION_SERVICE
      LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

      //        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 200000, 0,
      // this);
      //        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 200000, 0,
      // this);
      //        locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 200000, 0,
      // this);

      // Creating a criteria object to retrieve provider
      Criteria criteria = new Criteria();

      // Getting the name of the best provider
      String provider = locationManager.getBestProvider(criteria, true);

      // Getting Current Location
      location = locationManager.getLastKnownLocation(provider);

      if (location != null) {
        onLocationChanged(location);
      }
    }

    setUpClusterer();
    // Add cluster items (markers) to the cluster manager.
    ShelterListAsync shelterListTask = new ShelterListAsync();
    shelterListTask.execute();
  }
Esempio n. 13
0
 /**
  * Verify that Google Play services is available before making a request.
  *
  * @return true if Google Play services is available, otherwise false
  */
 private boolean servicesConnected() {
   int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (ConnectionResult.SUCCESS == resultCode) {
     Log.d(ActivityUtils.APPTAG, getString(R.string.play_services_available));
     return true;
   } else {
     GooglePlayServicesUtil.getErrorDialog(resultCode, this, 0).show();
     return false;
   }
 }
 private boolean isPlayServicesConfigured() {
   int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(MapActivity.this);
   if (status == ConnectionResult.SUCCESS) return true;
   else {
     // Log.d("STATUS", "Error connecting with Google Play services. Code: " +
     // String.valueOf(status));
     Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, MapActivity.this, status);
     dialog.show();
     return false;
   }
 }
 /**
  * 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() {
   int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (resultCode != ConnectionResult.SUCCESS) {
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
       GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST)
           .show();
     }
     return false;
   }
   return true;
 }
 /**
  * Utility method that checks whether Google Play Services is installed and up to date, and
  * displays a notification for the user to update if no.
  *
  * @return true if installed
  */
 private boolean checkGooglePlayServicesAvailable() {
   final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) {
     Dialog dialog =
         GooglePlayServicesUtil.getErrorDialog(
             connectionStatusCode, this, REQ_GOOGLE_PLAY_SERVICES);
     dialog.show();
     return false;
   }
   return true;
 }
Esempio n. 17
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // Getting status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    // Showing status
    if (status == ConnectionResult.SUCCESS) {

    } else {

      int requestCode = 10;
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
      dialog.show();
      return;
    }

    // requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    if (savedInstanceState != null) {
      allTapItem = (ArrayList<OSMNode>) savedInstanceState.get("allTapItem");
      allToiletItem = (ArrayList<OSMNode>) savedInstanceState.get("allToiletItem");
      allFoodItem = (ArrayList<OSMNode>) savedInstanceState.get("allFoodItem");
    }
    // TODO Semi-Transparent Action Bar
    // requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    // getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_black));

    setContentView(R.layout.activity_main);
    configureActionBar();
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    mMapFragment = getSupportFragmentManager().findFragmentByTag("map");
    if (mMapFragment == null) {
      // If not, instantiate and add it to the activity
      mMapFragment = new ViewMapFragment_();
      ft.add(R.id.container, mMapFragment, "map").commit();
    } else {
      // If it exists, simply attach it in order to show it
      ft.show(mMapFragment).commit();
    }
    TapForTap.initialize(this, "ef3209aec5ac8e0eb9682b8890b20a78");
    adview = (AdView) findViewById(R.id.adView);
    adview.setAdListener(this);
    ImageButton imgbtn = (ImageButton) findViewById(R.id.closeadbtn);
    imgbtn.setVisibility(View.GONE);

    // Initiate a generic request to load it with an ad
    AdRequest request = new AdRequest();
    adview.loadAd(request);

    // Search markers
    searchMarkers = new ArrayList<Marker>();
  }
 @Override
 public void onConnectionFailed(ConnectionResult result) {
   if (!result.hasResolution()) {
     GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
     return;
   }
   try {
     result.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
   } catch (IntentSender.SendIntentException e) {
     Log.e(TAG, "Exception while starting resolution activity", e);
   }
 }
 public boolean serviceOK() {
   int isAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (isAvailable == ConnectionResult.SUCCESS) {
     return true;
   } else if (GooglePlayServicesUtil.isUserRecoverableError(isAvailable)) {
     Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvailable, this, 100);
     dialog.show();
   } else {
     Toast.makeText(this, "Something wrong!", Toast.LENGTH_LONG).show();
   }
   return false;
 }
Esempio n. 20
0
 private static boolean checkPlayServices() {
   int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
   if (resultCode != ConnectionResult.SUCCESS) {
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
       GooglePlayServicesUtil.getErrorDialog(resultCode, context, PLAY_SERVICES_RESOLUTION_REQUEST)
           .show();
     } else {
       Log.i(TAG, "This device is not supported.");
     }
     return false;
   }
   return true;
 }
Esempio n. 21
0
 private boolean checkPlayServices() {
   int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (resultCode != ConnectionResult.SUCCESS) {
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
       GooglePlayServicesUtil.getErrorDialog(resultCode, this, 1).show();
     } else {
       Log.i("CheckPlayServices", "Dispositivo no soportado.");
       finish();
     }
     return false;
   }
   return true;
 }
 /**
  * This function checks for GooglePlay Service availability
  *
  * @param activity
  * @return
  */
 public static boolean isPlayServiceAvailable(Activity activity) {
   int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
   if (resultCode != ConnectionResult.SUCCESS) {
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
       GooglePlayServicesUtil.getErrorDialog(resultCode, activity, PlayServiceResolutionRequest)
           .show();
     } else {
       Log.i(Tag, "This device is not supported.");
     }
     return false;
   }
   return true;
 }
Esempio n. 23
0
  /** Returns an error dialog that's appropriate for the given error code. */
  Dialog getErrorDialog(int errorCode) {
    debugLog("Making error dialog for error: " + errorCode);
    Dialog errorDialog =
        GooglePlayServicesUtil.getErrorDialog(errorCode, mActivity, RC_UNUSED, null);

    if (errorDialog != null) return errorDialog;

    // as a last-resort, make a sad "unknown error" dialog.
    return (new AlertDialog.Builder(getContext()))
        .setMessage(mUnknownErrorMessage)
        .setNeutralButton(android.R.string.ok, null)
        .create();
  }
Esempio n. 24
0
  public void setMapView() {
    campusMap =
        ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    // Con el fin de comprobar si el dispositivo cuenta con Google Play Services.
    if (campusMap != null) {
      // Setup your map...
    } else {
      int isEnabled = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
      if (isEnabled != ConnectionResult.SUCCESS) {
        GooglePlayServicesUtil.getErrorDialog(isEnabled, this, 0);
      }
    }
    //

    campusMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    campusMap.moveCamera(CameraUpdateFactory.newLatLngZoom(UniEafit, minZoom));

    campusMap.setMyLocationEnabled(true);

    // Se comprueba sí es necesario que el usuario aparezca en el mapa.
    Location userLocation = campusMap.getMyLocation();
    if (userLocation != null) {
      if (!campusMapBounds.contains(
          new LatLng(userLocation.getLatitude(), userLocation.getLongitude()))) {
        campusMap.setMyLocationEnabled(false);
      }
    }

    campusMap.getUiSettings().setZoomControlsEnabled(false);
    campusMap.getUiSettings().setCompassEnabled(true);
    Bundle paramsBag = getIntent().getExtras(); // 	Aquí estarían los parámetros recibidos.
    if (paramsBag != null && paramsBag.getBoolean("storeInfo")) { // La app viene del Log in.
      clearSharedPreferences();
      saveSharedPreferences();
    } else {
      checkUserData();
    }
    if (isInternetConnectionAvailable()) {
      wantedService = "Add main markers";
      POST_URL = "http://campusmovilapp.herokuapp.com/api/v1/markers";
      // Para dar autorización al acceso de los marcadores.
      new POSTConnection().execute(POST_URL);
    } else {
      Toast.makeText(
              getApplicationContext(),
              getResources().getString(R.string.internet_connection_required),
              Toast.LENGTH_SHORT)
          .show();
    }
  }
Esempio n. 25
0
  @Override
  public void onConnectionFailed(ConnectionResult result) {
    if (!result.hasResolution()) {
      GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
      return;
    }

    if (!intentInProgress) {
      connectionResult = result;
      if (isSignInClicked) {
        resolveSignInError();
      }
    }
  }
Esempio n. 26
0
  // check for google services is available or not
  public boolean servicesOK() {
    int isAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    if (isAvailable == ConnectionResult.SUCCESS) {
      return true;
    } else if (GooglePlayServicesUtil.isUserRecoverableError(isAvailable)) {
      Dialog dialog =
          GooglePlayServicesUtil.getErrorDialog(isAvailable, this, GPS_ERRORDIALOG_REQUEST);
      dialog.show();
    } else {
      Toast.makeText(this, "Can't connect to Google Play services", Toast.LENGTH_SHORT).show();
    }
    return false;
  }
Esempio n. 27
0
 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 {
       Logger.getInstance().w("This device is not supported.");
       finish();
     }
     return false;
   }
   return true;
 }
Esempio n. 28
0
 private boolean checkPlayServices() {
   int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (resultCode != ConnectionResult.SUCCESS) {
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
       GooglePlayServicesUtil.getErrorDialog(resultCode, this, 1000).show();
     } else {
       Toast.makeText(getApplicationContext(), "This device is not supported.", Toast.LENGTH_LONG)
           .show();
       finish();
     }
     return false;
   }
   return true;
 }
  /** Checks to see if Google Play Services is installed on the phone, which is required. */
  private void checkGooglePlayServices() {
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    if (status != ConnectionResult.SUCCESS) {
      if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
        Dialog googlePlayError = GooglePlayServicesUtil.getErrorDialog(status, this, 0);
        googlePlayError.setCancelable(false);
        googlePlayError.setCanceledOnTouchOutside(false);
        googlePlayError.show();
      } else {
        Toast.makeText(this, "This device is not supported.", Toast.LENGTH_LONG).show();
        finish();
      }
    }
  }
Esempio n. 30
0
 @Override
 public void onConnectionFailed(ConnectionResult connectionResult) {
   if (!connectionResult.hasResolution()) {
     GooglePlayServicesUtil.getErrorDialog(
             connectionResult.getErrorCode(), this, ERROR_DIALOG_REQUEST_CODE)
         .show();
     return;
   }
   if (!mIntentInProgress) {
     mconnectionResult = connectionResult;
     if (mSignedInClicked) {
       processSignInError();
     }
   }
 }