public override void OnCreate() { mGeofenceList = new List <IGeofence>(); Dictionary <string, double> nord = new Dictionary <string, double>() { { "lat", 39.716864 }, { "lng", -104.955342 } }; Dictionary <string, double> test = new Dictionary <string, double>() { { "lat", 39.716 }, { "lng", -104.955 } }; GeofencingClient geofencingClient = LocationServices.GetGeofencingClient(this); mGeofenceList.Add(new GeofenceBuilder() .SetRequestId("nord") .SetCircularRegion(nord["lat"], nord["lng"], 3f) .SetExpirationDuration(Geofence.NeverExpire) .SetTransitionTypes(Geofence.GeofenceTransitionEnter | Geofence.GeofenceTransitionExit) .Build()); geofencingClient.AddGeofences(GetGeofencingRequest(), GetGeofencePendingIntent()); Console.WriteLine("WTF WTF WTF WTF"); Log.Debug("THIS", "WTF Created!"); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var locationClient = LocationServices.GetFusedLocationProviderClient(this); var geofencingClient = LocationServices.GetGeofencingClient(this); var lastLocation = await locationClient.GetLastLocationAsync(); var geoFence = new GeofenceBuilder() .SetRequestId("fence") .SetCircularRegion(lastLocation.Latitude, lastLocation.Longitude, 100) .SetTransitionTypes(Geofence.GeofenceTransitionExit | Geofence.GeofenceTransitionEnter) .SetExpirationDuration(Geofence.NeverExpire) .Build(); var geofenceRequest = new GeofencingRequest.Builder() .SetInitialTrigger(GeofencingRequest.InitialTriggerEnter) .AddGeofence(geoFence) .Build(); var geoIntent = new Intent(this, typeof(GeofenceTransitionsService)); var pendingGeoIntent = PendingIntent.GetService(this, 0, geoIntent, PendingIntentFlags.UpdateCurrent); geofencingClient.AddGeofences(geofenceRequest, pendingGeoIntent); }
/// <summary> /// 登録後のリスナーを指定してクラスをインスタンス化します。 /// </summary> /// <param name="context"></param> /// <param name="completeListener"></param> public RegisterGeofences(Context context, IGeofenceRegisterCompleteListener completeListener) { _context = context; _geofencingClient = LocationServices.GetGeofencingClient(context); CompleteListener = completeListener; PopulateGeofenceList(); }
private async void SetGeofence() { var locationClient = LocationServices.GetFusedLocationProviderClient(this); var geofencingClient = LocationServices.GetGeofencingClient(this); var lastLocation = await locationClient.GetLastLocationAsync(); var geoFence = new GeofenceBuilder() .SetRequestId("fence") .SetCircularRegion(lastLocation.Latitude, lastLocation.Longitude, 100) .SetTransitionTypes(Geofence.GeofenceTransitionExit | Geofence.GeofenceTransitionEnter) .SetExpirationDuration(Geofence.NeverExpire) .Build(); var geofenceRequest = new GeofencingRequest.Builder() .AddGeofence(geoFence) .Build(); var geoIntent = new Intent(ApplicationContext, typeof(GeofenceTransitionsService)); var pendingGeoIntent = PendingIntent.GetService(this, 0, geoIntent, PendingIntentFlags.UpdateCurrent); geofencingClient.AddGeofences(geofenceRequest, pendingGeoIntent); }
private void InitializeGoogleAPI() { int queryResult = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(Android.App.Application.Context); if (queryResult == ConnectionResult.Success) { string message = string.Format("{0} - {1}", CrossGeofence.Id, "Google Play services is available."); System.Diagnostics.Debug.WriteLine(message); if (mGeofenceClient == null) { mGeofenceClient = LocationServices.GetGeofencingClient(Android.App.Application.Context); } if (mFusedLocationClient == null) { var locationRequest = GetLocationRequest(); mFusedLocationClient = LocationServices.GetFusedLocationProviderClient(Android.App.Application.Context); mFusedLocationClient.RequestLocationUpdatesAsync(locationRequest, new FusedLocationCallback(this)); } //if (!mGoogleApiClient.IsConnected) //{ // mGoogleApiClient.Connect(); //} } else { string message = string.Format("{0} - {1}", CrossGeofence.Id, "Google Play services is unavailable."); System.Diagnostics.Debug.WriteLine(message); CrossGeofence.GeofenceListener.OnError(message); } }
public GeofenceManagerImpl(AndroidContext context, IRepository repository, IGeofenceDelegate geofenceDelegate) : base(repository) { this.context = context; this.client = LocationServices.GetGeofencingClient(this.context.AppContext); this.geofenceDelegate = geofenceDelegate; }
public GeofenceManagerImpl(IAndroidContext context, IRepository repository, IServiceProvider services, ILogger <GeofenceManagerImpl> logger) : base(repository) { this.context = context; this.logger = logger; this.services = services; this.client = LocationServices.GetGeofencingClient(this.context.AppContext); }
public GeofenceManagerImpl(AndroidContext context, IRepository repository) : base(repository) { this.context = context; this.client = LocationServices.GetGeofencingClient(this.context.AppContext); //mGoogleApiClient = new GoogleApiClient.Builder(this) // .addConnectionCallbacks(this) // .addOnConnectionFailedListener(this) // .addApi(LocationServices.API) // .build(); //this.client.Connect(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.main_activity); mAddGeofencesButton = FindViewById <Button>(Resource.Id.add_geofences_button); mRemoveGeofencesButton = FindViewById <Button>(Resource.Id.remove_geofences_button); mGeofenceList = new List <IGeofence>(); mGeofencePendingIntent = null; SetButtonsEnabledState(); PopulateGeofenceList(); mGeofencingClient = LocationServices.GetGeofencingClient(this); mAddGeofencesButton.Click += AddGeofencesButtonHandler; mRemoveGeofencesButton.Click += RemoveGeofencesButtonHandler; }
public void IsLocationEnabled(Action <bool> returnAction) { lock (Lock) { InitializeGoogleAPI(); if (mGoogleApiClient == null || CheckPermissions() == false) { returnAction(false); return; } mFusedLocationProviderClient = LocationServices.GetFusedLocationProviderClient(Android.App.Application.Context); mGeofencingClient = LocationServices.GetGeofencingClient(Application.Context); mGeofenceList = new List <Android.Gms.Location.IGeofence>(); var locationRequestPriority = LocationRequest.PriorityBalancedPowerAccuracy; switch (CrossGeofence.GeofencePriority) { case GeofencePriority.HighAccuracy: locationRequestPriority = LocationRequest.PriorityHighAccuracy; break; case GeofencePriority.LowAccuracy: locationRequestPriority = LocationRequest.PriorityLowPower; break; case GeofencePriority.LowestAccuracy: locationRequestPriority = LocationRequest.PriorityNoPower; break; } mLocationRequest = new LocationRequest(); mLocationRequest.SetPriority(locationRequestPriority); mLocationRequest.SetInterval(CrossGeofence.LocationUpdatesInterval); mLocationRequest.SetFastestInterval(CrossGeofence.FastestLocationUpdatesInterval); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().AddLocationRequest(mLocationRequest); var pendingResult = LocationServices.SettingsApi.CheckLocationSettings(mGoogleApiClient, builder.Build()); pendingResult.SetResultCallback((LocationSettingsResult locationSettingsResult) => { if (locationSettingsResult != null) { returnAction(locationSettingsResult.Status.StatusCode <= CommonStatusCodes.Success); } }); System.Diagnostics.Debug.WriteLine("End of IsLocationEnabled, clients should be created"); } }
public GeofenceService(Context context) { _context = context; _geofenceClient = LocationServices.GetGeofencingClient(context); _regions = new List <IGeofence>(); }
public GeofencesService() { geofencingClient = LocationServices.GetGeofencingClient(MainActivity.MainContext); }
/// <summary> /// クラスをインスタンス化します。 /// </summary> /// <param name="context">AppContext</param> public RegisterGeofences(Context context) { _context = context; _geofencingClient = LocationServices.GetGeofencingClient(context); PopulateGeofenceList(); }
public GeofenceManagerImpl(IAndroidContext context, IRepository repository) : base(repository) { this.context = context; this.client = LocationServices.GetGeofencingClient(this.context.AppContext); }
public GeofencingImplementation() { syncLock = new object(); client = LocationServices.GetGeofencingClient(Application.Context); regions = MarcelloDatabase.Current.GetAll <GeofenceRegion>().ToList(); }