Example #1
0
        void AddRegionsToApi( )
        {
            // setup our Geofencing API.
            GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
            builder.SetInitialTrigger(GeofencingRequest.InitialTriggerEnter);

            // add each geofence to the Geofence API
            List <IGeofence> geoFences = new List <IGeofence>();

            foreach (TrackedRegion region in Regions)
            {
                geoFences.Add(region.Region);
            }
            builder.AddGeofences(geoFences);
            GeofencingRequest geofenceRequest = builder.Build( );


            // create the intent that should be launched when a geofence is triggered
            Intent        intent        = new Intent(this, typeof(LocationManagerService));
            PendingIntent pendingIntent = PendingIntent.GetService(this, 0, intent, PendingIntentFlags.UpdateCurrent);

            Android.Gms.Common.Apis.IPendingResult iAddPendingResult = LocationServices.GeofencingApi.AddGeofences(ILocationServiceApi, geofenceRequest, pendingIntent);
            iAddPendingResult.SetResultCallback(this);
        }
 public static async Task <Statuses> AddGeofencesAsync(this IGeofencingApi api, GoogleApiClient client, GeofencingRequest geofencingRequest, Android.App.PendingIntent pendingIntent)
 {
     return((await api.AddGeofences(client, geofencingRequest, pendingIntent)).JavaCast <Statuses> ());
 }
 public Task AddGeofencesAsync(GeofencingRequest geofenceRequest, Android.App.PendingIntent pendingIntent)
 {
     return(AddGeofences(geofenceRequest, pendingIntent).AsAsync());
 }