public DroidSensors(SensorTypes sensorTypes) { this.sensorManager = Application.Context.GetSystemService(Context.SensorService) as SensorManager; this.sensorListener = new DroidSensorListener(); // Accelerometer if (sensorTypes.HasFlag(SensorTypes.Accelerometer)) { this.accelerometer = this.sensorManager.GetDefaultSensor(SensorType.Accelerometer); } // Gyroscope if (sensorTypes.HasFlag(SensorTypes.Gyroscope)) { this.gyroscope = this.sensorManager.GetDefaultSensor(SensorType.Gyroscope); } }
public override bool Initialize(SensorTypes sensorTypes) { if (!this.Initialized) { // Accelerometer if (sensorTypes.HasFlag(SensorTypes.Accelerometer)) { this.accelerometer = this.sensorManager.GetDefaultSensor(SensorType.Accelerometer); } // Gyroscope if (sensorTypes.HasFlag(SensorTypes.Gyroscope)) { this.gyroscope = this.sensorManager.GetDefaultSensor(SensorType.Gyroscope); } this.Initialized = true; return(true); } return(false); }