コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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!");
        }
コード例 #3
0
 /// <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();
 }
コード例 #4
0
ファイル: GeofenceManagerImpl.cs プロジェクト: wolfet/shiny
 public GeofenceManagerImpl(AndroidContext context,
                            IRepository repository,
                            IGeofenceDelegate geofenceDelegate) : base(repository)
 {
     this.context          = context;
     this.client           = LocationServices.GetGeofencingClient(this.context.AppContext);
     this.geofenceDelegate = geofenceDelegate;
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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();
 }
コード例 #7
0
        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;
        }
コード例 #8
0
        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");
            }
        }
コード例 #9
0
 public GeofenceService(Context context)
 {
     _context        = context;
     _geofenceClient = LocationServices.GetGeofencingClient(context);
     _regions        = new List <IGeofence>();
 }
コード例 #10
0
 public GeofencesService()
 {
     geofencingClient = LocationServices.GetGeofencingClient(MainActivity.MainContext);
 }
コード例 #11
0
 /// <summary>
 /// クラスをインスタンス化します。
 /// </summary>
 /// <param name="context">AppContext</param>
 public RegisterGeofences(Context context)
 {
     _context          = context;
     _geofencingClient = LocationServices.GetGeofencingClient(context);
     PopulateGeofenceList();
 }
コード例 #12
0
 public GeofenceManagerImpl(IAndroidContext context, IRepository repository) : base(repository)
 {
     this.context = context;
     this.client  = LocationServices.GetGeofencingClient(this.context.AppContext);
 }
コード例 #13
0
 public GeofencingImplementation()
 {
     syncLock = new object();
     client   = LocationServices.GetGeofencingClient(Application.Context);
     regions  = MarcelloDatabase.Current.GetAll <GeofenceRegion>().ToList();
 }