Search in sources :

Example 81 with SensorManager

use of android.hardware.SensorManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DoubleTwistPreferenceController method isGestureAvailable.

public static boolean isGestureAvailable(Context context) {
    final Resources resources = context.getResources();
    final String name = resources.getString(R.string.gesture_double_twist_sensor_name);
    final String vendor = resources.getString(R.string.gesture_double_twist_sensor_vendor);
    if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(vendor)) {
        final SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
        for (Sensor s : sensorManager.getSensorList(Sensor.TYPE_ALL)) {
            if (name.equals(s.getName()) && vendor.equals(s.getVendor())) {
                return true;
            }
        }
    }
    return false;
}
Also used : SensorManager(android.hardware.SensorManager) Resources(android.content.res.Resources) Sensor(android.hardware.Sensor)

Example 82 with SensorManager

use of android.hardware.SensorManager in project gdk-compass-sample by googleglass.

the class CompassService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    // Even though the text-to-speech engine is only used in response to a menu action, we
    // initialize it when the application starts so that we avoid delays that could occur
    // if we waited until it was needed to start it up.
    mSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {

        @Override
        public void onInit(int status) {
        // Do nothing.
        }
    });
    SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mOrientationManager = new OrientationManager(sensorManager, locationManager);
    mLandmarks = new Landmarks(this);
}
Also used : LocationManager(android.location.LocationManager) SensorManager(android.hardware.SensorManager) Landmarks(com.google.android.glass.sample.compass.model.Landmarks) TextToSpeech(android.speech.tts.TextToSpeech)

Example 83 with SensorManager

use of android.hardware.SensorManager in project sensey by nisrulz.

the class SenseyTest method setUp.

@Before
public void setUp() {
    Context context = ApplicationProvider.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 84 with SensorManager

use of android.hardware.SensorManager in project edx-app-android by edx.

the class OrientationDetector method stop.

public void stop() {
    SensorManager mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    mSensorManager.unregisterListener(this);
    logger.warn("stopped orientation sensor");
}
Also used : SensorManager(android.hardware.SensorManager)

Example 85 with SensorManager

use of android.hardware.SensorManager in project edx-app-android by edx.

the class OrientationDetector method start.

public void start() {
    SensorManager mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    Sensor mSensorOrientation = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    if (mSensorOrientation != null) {
        mSensorManager.registerListener(this, mSensorOrientation, SensorManager.SENSOR_DELAY_NORMAL);
        logger.debug("started sensor: " + mSensorOrientation.toString());
    } else {
        logger.warn("sensor NOT available");
    }
}
Also used : SensorManager(android.hardware.SensorManager) Sensor(android.hardware.Sensor)

Aggregations

SensorManager (android.hardware.SensorManager)89 Sensor (android.hardware.Sensor)29 SharedPreferences (android.content.SharedPreferences)12 Resources (android.content.res.Resources)8 PowerManager (android.os.PowerManager)6 ContentResolver (android.content.ContentResolver)5 IntentFilter (android.content.IntentFilter)5 SystemSensorManager (android.hardware.SystemSensorManager)5 IPowerManager (android.os.IPowerManager)5 RemoteException (android.os.RemoteException)5 WindowManager (android.view.WindowManager)5 DisplayManagerInternal (android.hardware.display.DisplayManagerInternal)4 BatteryManagerInternal (android.os.BatteryManagerInternal)4 DreamManagerInternal (android.service.dreams.DreamManagerInternal)4 IVrManager (android.service.vr.IVrManager)4 Display (android.view.Display)4 WindowManagerPolicy (android.view.WindowManagerPolicy)4 LightsManager (com.android.server.lights.LightsManager)4 SuppressLint (android.annotation.SuppressLint)3 Intent (android.content.Intent)3