use of android.hardware.SensorManager in project zxing-android-embedded by journeyapps.
the class AmbientLightManager method stop.
public void stop() {
if (lightSensor != null) {
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
sensorManager.unregisterListener(this);
lightSensor = null;
}
}
use of android.hardware.SensorManager in project zxing-android-embedded by journeyapps.
the class AmbientLightManager method start.
public void start() {
if (cameraSettings.isAutoTorchEnabled()) {
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
if (lightSensor != null) {
sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
}
}
use of android.hardware.SensorManager in project libgdx by libgdx.
the class AndroidInput method registerSensorListeners.
void registerSensorListeners() {
if (config.useAccelerometer) {
manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).size() == 0) {
accelerometerAvailable = false;
} else {
Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
accelerometerListener = new SensorListener(this.nativeOrientation, this.accelerometerValues, this.magneticFieldValues, this.gyroscopeValues);
accelerometerAvailable = manager.registerListener(accelerometerListener, accelerometer, SensorManager.SENSOR_DELAY_GAME);
}
} else
accelerometerAvailable = false;
if (config.useGyroscope) {
manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
if (manager.getSensorList(Sensor.TYPE_GYROSCOPE).size() == 0) {
gyroscopeAvailable = false;
} else {
Sensor gyroscope = manager.getSensorList(Sensor.TYPE_GYROSCOPE).get(0);
gyroscopeListener = new SensorListener(this.nativeOrientation, this.gyroscopeValues, this.magneticFieldValues, this.gyroscopeValues);
gyroscopeAvailable = manager.registerListener(gyroscopeListener, gyroscope, SensorManager.SENSOR_DELAY_GAME);
}
} else
gyroscopeAvailable = false;
if (config.useCompass) {
if (manager == null)
manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor sensor = manager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
if (sensor != null) {
compassAvailable = accelerometerAvailable;
if (compassAvailable) {
compassListener = new SensorListener(this.nativeOrientation, this.accelerometerValues, this.magneticFieldValues, this.gyroscopeValues);
compassAvailable = manager.registerListener(compassListener, sensor, SensorManager.SENSOR_DELAY_GAME);
}
} else {
compassAvailable = false;
}
} else
compassAvailable = false;
Gdx.app.log("AndroidInput", "sensor listener setup");
}
use of android.hardware.SensorManager in project sensey by nisrulz.
the class SenseyTest method setUp.
@Before
public void setUp() {
Context context = RuntimeEnvironment.application.getApplicationContext();
shadowSensorManager = Shadows.shadowOf((SensorManager) context.getSystemService(SENSOR_SERVICE));
sensey = Sensey.getInstance();
sensey.init(context);
}
use of android.hardware.SensorManager in project platform_frameworks_base by android.
the class GestureLauncherService method unregisterCameraLaunchGesture.
private void unregisterCameraLaunchGesture() {
if (mRegistered) {
mRegistered = false;
mCameraGestureOnTimeMs = 0L;
mCameraGestureLastEventTime = 0L;
mCameraGestureSensor1LastOnTimeMs = 0;
mCameraGestureSensor2LastOnTimeMs = 0;
mCameraLaunchLastEventExtra = 0;
SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
sensorManager.unregisterListener(mGestureListener);
}
}
Aggregations