示例#1
0
        public void CreateGeofences()
        {
            // Create internal "flattened" objects containing the geofence data
            mAndroidBuildingGeofence = new SimpleGeofence(
                Constants.ANDROID_BUILDING_ID,                 // geofenceId
                Constants.ANDROID_BUILDING_LATITUDE,
                Constants.ANDROID_BUILDING_LONGITUDE,
                Constants.ANDROID_BUILDING_RADIUS_METERS,
                Constants.GEOFENCE_EXPIRATION_TIME,
                Geofence.GeofenceTransitionEnter | Geofence.GeofenceTransitionExit
                );
            mYerbaBuenaGeofence = new SimpleGeofence(
                Constants.YERBA_BUENA_ID,                 // geofenceId
                Constants.YERBA_BUENA_LATITUDE,
                Constants.YERBA_BUENA_LONGITUDE,
                Constants.YERBA_BUENA_RADIUS_METERS,
                Constants.GEOFENCE_EXPIRATION_TIME,
                Geofence.GeofenceTransitionEnter | Geofence.GeofenceTransitionExit
                );

            // Store these flat versions in SharedPreferences and add them to the geofence list
            mGeofenceStorage.SetGeofence(Constants.ANDROID_BUILDING_ID, mAndroidBuildingGeofence);
            mGeofenceStorage.SetGeofence(Constants.YERBA_BUENA_ID, mYerbaBuenaGeofence);
            mGeofenceList.Add(mAndroidBuildingGeofence.ToGeofence());
            mGeofenceList.Add(mYerbaBuenaGeofence.ToGeofence());
        }