public void OnSensorChanged(SensorEvent e) { try { if (e.Sensor.Type == SensorType.Proximity) { if (e.Values[0] >= -SENSOR_SENSITIVITY && e.Values[0] <= SENSOR_SENSITIVITY) { //near GlobalContext?.SetOffWakeLock(); } else { //far GlobalContext?.SetOnWakeLock(); } } } catch (Exception exception) { Console.WriteLine(exception); } }