private void Initialize() { locationUpdateReceiver = new LocationBroadcastReceiver(); locationUpdateReceiver.locationUpdate += onNewLocationUpdate; locationUpdateReceiver.SendUpdate += onNewSentUpdate; locationUpdateReceiver.ConnectionStateChange += onStateChange; sentTimeUpdate = new System.Timers.Timer(); sentTimeUpdate.Interval = 1000 * 5; sentTimeUpdate.Elapsed += updateLastSent; sentTimeUpdate.AutoReset = true; lastUpdate = DateTime.MinValue; }
/// <summary> /// Initializes the Broadcast receivers /// </summary> private void initReceiver() { IntentFilter fil; // Location Receiver locationReceiver = new LocationBroadcastReceiver(); // Sensor Receiver sensorStateReceiver = new SensorStateBroadcastReceiver(); sensorStateReceiver.SensorAdded += SensorAdded; sensorStateReceiver.SensorRemoved += SensorRemoved; sensorStateReceiver.SensorConnect += SensorConnect; sensorStateReceiver.SensorDisconnect += SensorDisconnect; sensorStateReceiver.SensorReportingPaused += SensorPause; RegisterReceiver(); }
/// <summary> /// Registers the Broadcast receivers /// </summary> private void RegisterReceiver() { IntentFilter fil; // Location Receiver locationReceiver = new LocationBroadcastReceiver(); fil = new IntentFilter(AppUtil.LOCATION_UPDATE_ACTION); fil.Priority = 98; Android.App.Application.Context.RegisterReceiver(locationReceiver, fil); fil = new IntentFilter(); fil.AddAction(AppUtil.SENSOR_CONNECT_ACTION); fil.AddAction(AppUtil.SENSOR_REMOVED_ACTION); fil.AddAction(AppUtil.SENSOR_ADDED_ACTION); fil.AddAction(AppUtil.SENSOR_DISCONNECT_ACTION); fil.AddAction(AppUtil.SENSOR_PAUSE_ACTION); fil.Priority = 97; Android.App.Application.Context.RegisterReceiver(sensorStateReceiver, fil); }