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);
}
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;
}
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);
}
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);
}
}
}
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;
}
}
Aggregations