Java 类com.google.android.gms.location.GeofencingApi 实例源码

项目:Didgeridone-Android    文件:MainActivity.java   
/**
 * Removes geofences, which stops further notifications when the device enters or exits
 * previously registered geofences.
 */
public void removeGeofences() {
    if (!mGoogleApiClient.isConnected()) {
        Toast.makeText(this, getString(R.string.not_connected), Toast.LENGTH_SHORT).show();
        return;
    }
    try {
        // Remove geofences.
        LocationServices.GeofencingApi.removeGeofences(
                mGoogleApiClient,
                // This is the same pending intent that was used in addGeofences().
                getGeofencePendingIntent()
        ).setResultCallback(this); // Result processed in onResult().
        geofencesAddedButtonState(false);

    } catch (SecurityException securityException) {
        // Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
        logSecurityException(securityException);
        geofencesAddedButtonState(true);
    }
}
项目:LETO-Toggl_Android    文件:GeofenceActivity.java   
public void addGeofences() {
    if (!mGoogleApiClient.isConnected()) {
        Log.e(TAG, "GOOGLE API CLIENT NOT CONNECTED!!!! ");
        isWaitingToAdd=true;
        return;
    }

    try {
        Log.i(TAG, "GEOFENCE ADDED!");
        LocationServices.GeofencingApi.addGeofences(
                mGoogleApiClient,
                // The GeofenceRequest object.
                getGeofencingRequest(),
                // A pending intent that that is reused when calling removeGeofences(). This
                // pending intent is used to generate an intent when a matched geofence
                // transition is observed.
                getGeofencePendingIntent()
        ).setResultCallback(this); // Result processed in onResult().
    } catch (SecurityException securityException) {
        // Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
        logSecurityException(securityException);
    }
}
项目:LETO-Toggl_Android    文件:GeofenceActivity.java   
/**
 * Removes geofences, which stops further notifications when the device enters or exits
 * previously registered geofences.
 */
public void removeGeofences() {
    if (!mGoogleApiClient.isConnected()) {
        Log.e(TAG, "GOOGLE API CLIENT NOT CONNECTED!!!! ");
        isWaitingToRemove=true;
        return;
    }
    try {
        Log.i(TAG, "GEOFENCE REMOVED!");
        // Remove geofences.
        LocationServices.GeofencingApi.removeGeofences(
                mGoogleApiClient,
                // This is the same pending intent that was used in addGeofences().
                getGeofencePendingIntent()
        ).setResultCallback(this); // Result processed in onResult().
    } catch (SecurityException securityException) {
        // Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
        logSecurityException(securityException);
    }
}
项目:Check-Me-In    文件:AddGeofence.java   
@Override
public void onConnected(Bundle bundle) {
    // Now we can do the actual logic

    List<Geofence> fences = new ArrayList<Geofence>();
    fences.add(fence.toGeofence(venue));

    geofencingapi = LocationServices.GeofencingApi;

    if(locationClient != null && locationClient.isConnected() && fences.size() > 0){
        GeofencingRequest request = new GeofencingRequest.Builder()
                .addGeofences(fences)
                .build();
        PendingResult<Status> status = geofencingapi.addGeofences(locationClient, request, geofenceUtils.getTransitionPendingIntent(this));
        status.setResultCallback(this, 10, TimeUnit.SECONDS);

        // disconnect will be done in resultlistener
    }else if(locationClient != null && locationClient.isConnected()){
        locationClient.disconnect();
    }
}
项目:Didgeridone-Android    文件:MainActivity.java   
/**
 * Adds geofences, which sets alerts to be notified when the device enters or exits one of the
 * specified geofences. Handles the success or failure results returned by addGeofences().
 */
public void addGeofences() {

    if (!mGoogleApiClient.isConnected()) {
        Toast.makeText(this, getString(R.string.not_connected), Toast.LENGTH_SHORT).show();
        return;
    }

    try {
        LocationServices.GeofencingApi.addGeofences(
                mGoogleApiClient,
                // The GeofenceRequest object.
                getGeofencingRequest(),
                // A pending intent that that is reused when calling removeGeofences(). This
                // pending intent is used to generate an intent when a matched geofence
                // transition is observed.
                getGeofencePendingIntent()
        ).setResultCallback(this); // Result processed in onResult().

        geofencesAddedButtonState(true);

    } catch (SecurityException securityException) {
        // Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
        logSecurityException(securityException);
        geofencesAddedButtonState(false);
    }
}
项目:Check-Me-In    文件:AddConfigActivity.java   
@Override
public void onConnected(Bundle bundle) {
    LOGD(TAG, "connected");
    geofencingapi = LocationServices.GeofencingApi;
}