protected override void OnDestroy() { base.OnDestroy(); try { DestroyClassifier(); } catch (Exception ex) { // close quietly Log.Debug(TAG, ex.ToString()); } try { CloseCamera(); } catch (Exception ex) { // close quietly Log.Debug(TAG, ex.ToString()); } try { if (_buttonInputDriver != null) { _buttonInputDriver.Close(); } } catch (Exception ex) { // close quietly Log.Debug(TAG, ex.ToString()); } }
protected override void OnDestroy() { base.OnDestroy(); // Clean up sensor registrations _sensorManager.UnregisterListener(new TemperatureListener(this)); _sensorManager.UnregisterListener(new PressureListener(this)); // Clean up peripheral. if (_environmentalSensorDriver != null) { try { _environmentalSensorDriver.Close(); } catch (IOException e) { e.PrintStackTrace(); } _environmentalSensorDriver = null; } if (_buttonInputDriver != null) { try { _buttonInputDriver.Close(); } catch (IOException e) { e.PrintStackTrace(); } _buttonInputDriver = null; } if (_display != null) { try { _display.Clear(); _display.SetEnabled(false); _display.Close(); } catch (IOException e) { e.PrintStackTrace(); } finally { _display = null; } } if (_ledStrip != null) { try { _ledStrip.Brightness = 0; _ledStrip.Write(new int[7]); _ledStrip.Close(); } catch (IOException e) { e.PrintStackTrace(); } finally { _ledStrip = null; } } if (_led != null) { try { _led.Value = false; _led.Close(); } catch (IOException e) { e.PrintStackTrace(); } finally { _led = null; } } //TODO https://github.com/androidthings/weatherstation/blob/master/app/src/main/java/com/example/androidthings/weatherstation/WeatherStationActivity.java#L304 }