use of android.hardware.SensorManager in project platform_frameworks_base by android.
the class GestureLauncherService method registerCameraLaunchGesture.
/**
* Registers for the camera launch gesture.
*/
private void registerCameraLaunchGesture(Resources resources) {
if (mRegistered) {
return;
}
mCameraGestureOnTimeMs = SystemClock.elapsedRealtime();
mCameraGestureLastEventTime = mCameraGestureOnTimeMs;
SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
int cameraLaunchGestureId = resources.getInteger(com.android.internal.R.integer.config_cameraLaunchGestureSensorType);
if (cameraLaunchGestureId != -1) {
mRegistered = false;
String sensorName = resources.getString(com.android.internal.R.string.config_cameraLaunchGestureSensorStringType);
mCameraLaunchSensor = sensorManager.getDefaultSensor(cameraLaunchGestureId, true);
// makes the code more robust.
if (mCameraLaunchSensor != null) {
if (sensorName.equals(mCameraLaunchSensor.getStringType())) {
mRegistered = sensorManager.registerListener(mGestureListener, mCameraLaunchSensor, 0);
} else {
String message = String.format("Wrong configuration. Sensor type and sensor " + "string type don't match: %s in resources, %s in the sensor.", sensorName, mCameraLaunchSensor.getStringType());
throw new RuntimeException(message);
}
}
if (DBG)
Slog.d(TAG, "Camera launch sensor registered: " + mRegistered);
} else {
if (DBG)
Slog.d(TAG, "Camera launch sensor is not specified.");
}
}
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 zxingfragmentlib by mitoyarzun.
the class AmbientLightManager method stop.
public void stop() {
if (lightSensor != null) {
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
sensorManager.unregisterListener(this);
cameraManager = null;
lightSensor = null;
}
}
use of android.hardware.SensorManager in project android_frameworks_base by AOSPA.
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);
}
}
use of android.hardware.SensorManager in project android_frameworks_base by AOSPA.
the class GestureLauncherService method registerCameraLaunchGesture.
/**
* Registers for the camera launch gesture.
*/
private void registerCameraLaunchGesture(Resources resources) {
if (mRegistered) {
return;
}
mCameraGestureOnTimeMs = SystemClock.elapsedRealtime();
mCameraGestureLastEventTime = mCameraGestureOnTimeMs;
SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
int cameraLaunchGestureId = resources.getInteger(com.android.internal.R.integer.config_cameraLaunchGestureSensorType);
if (cameraLaunchGestureId != -1) {
mRegistered = false;
String sensorName = resources.getString(com.android.internal.R.string.config_cameraLaunchGestureSensorStringType);
mCameraLaunchSensor = sensorManager.getDefaultSensor(cameraLaunchGestureId, true);
// makes the code more robust.
if (mCameraLaunchSensor != null) {
if (sensorName.equals(mCameraLaunchSensor.getStringType())) {
mRegistered = sensorManager.registerListener(mGestureListener, mCameraLaunchSensor, 0);
} else {
String message = String.format("Wrong configuration. Sensor type and sensor " + "string type don't match: %s in resources, %s in the sensor.", sensorName, mCameraLaunchSensor.getStringType());
throw new RuntimeException(message);
}
}
if (DBG)
Slog.d(TAG, "Camera launch sensor registered: " + mRegistered);
} else {
if (DBG)
Slog.d(TAG, "Camera launch sensor is not specified.");
}
}
Aggregations