use of android.hardware.SensorManager in project Osmand by osmandapp.
the class DayNightHelper method startSensorIfNeeded.
public void startSensorIfNeeded(StateChangedListener<Boolean> sensorStateListener) {
this.sensorStateListener = sensorStateListener;
DayNightMode dayNightMode = pref.get();
if (listener == null && dayNightMode.isSensor()) {
SensorManager mSensorManager = (SensorManager) osmandApplication.getSystemService(Context.SENSOR_SERVICE);
Sensor mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
List<Sensor> list = mSensorManager.getSensorList(Sensor.TYPE_LIGHT);
// $NON-NLS-1$
log.info("Light sensors:" + list.size());
mSensorManager.registerListener(this, mLight, SensorManager.SENSOR_DELAY_NORMAL);
listener = this;
} else if (listener != null && !dayNightMode.isSensor()) {
stopSensorIfNeeded();
}
}
use of android.hardware.SensorManager in project SmartMesh_Android by SmartMeshFoundation.
the class AmbientLightManager method start.
public 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 SmartMesh_Android by SmartMeshFoundation.
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 MDM-Android-Agent by wso2-attic.
the class DeviceInfo method getAllSensors.
/**
*Returns all the sensors available on the device as a List
*/
public void getAllSensors() {
SensorManager sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
List<Sensor> list = sm.getSensorList(Sensor.TYPE_ALL);
if (CommonUtilities.DEBUG_MODE_ENABLED) {
for (Sensor s : list) {
Log.d("SENSORS", s.getName());
}
}
}
use of android.hardware.SensorManager in project android_packages_apps_Settings by DirtyUnicorns.
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;
}
Aggregations