Search in sources :

Example 71 with SensorManager

use of android.hardware.SensorManager in project SharedPreferenceInspector by PrashamTrivedi.

the class DemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    SharedPreferences defualtPref = PreferenceManager.getDefaultSharedPreferences(this);
    defualtPref.edit().putString("Test", "Done").apply();
    SharedPreferences anotherPref = getSharedPreferences("Prasham", MODE_PRIVATE);
    anotherPref.edit().putString("Test", "Love you life").apply();
    anotherPref.edit().putInt("Test Int", 1138).apply();
    anotherPref.edit().putFloat("Test Float", 11.38F).apply();
    anotherPref.edit().putLong("Test Long", 113834).apply();
    anotherPref.edit().putBoolean("Test Boolean", true).apply();
    SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    ShakeDetector sd = new ShakeDetector(this);
    sd.start(sensorManager);
}
Also used : SensorManager(android.hardware.SensorManager) SharedPreferences(android.content.SharedPreferences) ShakeDetector(com.squareup.seismic.ShakeDetector)

Example 72 with SensorManager

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

the class LevelService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (mLiveCard == null) {
        SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_TAG);
        mRenderer = new LevelRenderer(sensorManager, this);
        mLiveCard.setDirectRenderingEnabled(true);
        mLiveCard.getSurfaceHolder().addCallback(mRenderer);
        // Display the options menu when the live card is tapped.
        Intent menuIntent = new Intent(this, LevelMenuActivity.class);
        menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0));
        mLiveCard.publish(LiveCard.PublishMode.REVEAL);
    }
    return START_STICKY;
}
Also used : SensorManager(android.hardware.SensorManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 73 with SensorManager

use of android.hardware.SensorManager in project Rajawali by Rajawali.

the class AccelerometerFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mGravity = new float[3];
    SensorManager mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST);
}
Also used : SensorManager(android.hardware.SensorManager)

Example 74 with SensorManager

use of android.hardware.SensorManager in project incubator-weex by apache.

the class AmbientLightManager method start.

void start(CameraManager cameraManager) {
    this.cameraManager = cameraManager;
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
        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) SharedPreferences(android.content.SharedPreferences)

Example 75 with SensorManager

use of android.hardware.SensorManager in project incubator-weex by apache.

the class AmbientLightManager method stop.

void stop() {
    if (lightSensor != null) {
        SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
        sensorManager.unregisterListener(this);
        cameraManager = null;
        lightSensor = null;
    }
}
Also used : SensorManager(android.hardware.SensorManager)

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