Search in sources :

Example 21 with SensorManager

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;
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Example 22 with SensorManager

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);
        }
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Example 23 with SensorManager

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");
}
Also used : SensorManager(android.hardware.SensorManager) Sensor(android.hardware.Sensor)

Example 24 with SensorManager

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);
}
Also used : Context(android.content.Context) SensorManager(android.hardware.SensorManager) ShadowSensorManager(org.robolectric.shadows.ShadowSensorManager) Before(org.junit.Before)

Example 25 with SensorManager

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);
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Aggregations

SensorManager (android.hardware.SensorManager)41 SharedPreferences (android.content.SharedPreferences)7 PowerManager (android.os.PowerManager)6 ContentResolver (android.content.ContentResolver)5 IntentFilter (android.content.IntentFilter)5 Sensor (android.hardware.Sensor)5 SystemSensorManager (android.hardware.SystemSensorManager)5 IPowerManager (android.os.IPowerManager)5 DisplayManagerInternal (android.hardware.display.DisplayManagerInternal)4 BatteryManagerInternal (android.os.BatteryManagerInternal)4 RemoteException (android.os.RemoteException)4 DreamManagerInternal (android.service.dreams.DreamManagerInternal)4 IVrManager (android.service.vr.IVrManager)4 WindowManagerPolicy (android.view.WindowManagerPolicy)4 LightsManager (com.android.server.lights.LightsManager)4 WindowManager (android.view.WindowManager)3 Context (android.content.Context)2 LocationManager (android.location.LocationManager)2 Display (android.view.Display)2 ActivityManager (android.app.ActivityManager)1