android-sensors

How to detect user presence in android?

送分小仙女□ 提交于 2019-12-03 12:47:05
I know in Galaxy Samsung SIII it is possible to configure in settings an option to avoid the screen turns off when user is looking into the screen. I think the phone uses the camera or a kind of a sensor of presence. is it possible to do it programmatically? even if yes, some devices won't be capable to do that. I imagine some possibilities here: using the camera, accelerometer, or even user activity: if the screen is on, touches, I don't know. There is a specific library about "user presence" to android? Using the best of all sensors when available? Yes, there's something like that. You can

Android accelerometer, sensor usage and power consumption

醉酒当歌 提交于 2019-12-03 12:46:41
I have a quick question about the accelerometer in Android devices. Is it always on/active? Given that accelerometer is used to detect the orientation of the device, either landscape or portrait. In the official documentation ( SensorManager ) it states that sensors should be turned off to save power. But I wonder if this only applies to others sensors like magnetic field sensors, gyroscope, light sensor and so on. I need to make a case for power conservation and I don't want to make the mistake of saying that the accelerometer can at times be disabled, and instead use it for the purpose of

How to know if a sensor is present on my Android device?

大兔子大兔子 提交于 2019-12-03 11:40:27
问题 i would like to know if a sensor (for exemple the accellerometer) is present on my Android device. I am dealing with the SensorManager class. Here is the code I am using: sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE); sensorMgr.registerListener(this,sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),1); Thank you. 回答1: Your second line can be used for this: boolean accelerometer; accelerometer = sensorMgr.registerListener(this,sensorMgr.getDefaultSensor(Sensor.TYPE

extract yaw, pitch, and roll from a rotationMatrix

情到浓时终转凉″ 提交于 2019-12-03 05:47:20
问题 I have a sensor manager that returns a rotationMatrix based on the devices Magnetometer and Accelerometer. I have been trying to also calculate the yaw pitch and roll of the user's device but am finding that pitch and roll interfere with each other and give inaccurate results. Is there a way to extract YAW PITCH and ROLL of a device from the rotationMatrix ? EDIT Trying to interpret blender's answer below, which i am thankful for but not quite there yet, i am trying to get the angle from a

What is the difference between “gravity” and “acceleration” sensors in Android?

本秂侑毒 提交于 2019-12-03 04:40:13
What is the difference between gravity and acceleration sensors in Android? From my point of view the physical value is the same in both cases. Which one measures the force acting on unit mass inside the device? ADDITION The question is: what physical quantity is measured by these sensors? According to equivalence principle the acceleration and gravity are indistinguishable and the only way to measure both is by usual (but 3d) spring balance. Acceleration sensor gives you back the sum of all forces applied to your device, while Gravity sensor returns only the influence of gravity. If you want

what's wrong with my sensor monitoring technique?

做~自己de王妃 提交于 2019-12-03 03:32:33
(please read UPDATE 3 at the end)I'm developing an app that continually works with the sensors of device, works with Accelerometer and Magnetic sensors to retrieve the orientation of device(the purpose is mentioned here ). in other words, my app needs to know the orientation of device in Real-time(however this is never possible, so as fast as possible instead, but really as fast as possible !). as mentioned in professional Android 4 Application Development by Reto Meier : The accelerometers can update hundreds of times a second... I must not lose any data that sensors report and I also want to

How to know if a sensor is present on my Android device?

有些话、适合烂在心里 提交于 2019-12-03 03:17:25
i would like to know if a sensor (for exemple the accellerometer) is present on my Android device. I am dealing with the SensorManager class. Here is the code I am using: sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE); sensorMgr.registerListener(this,sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),1); Thank you. Your second line can be used for this: boolean accelerometer; accelerometer = sensorMgr.registerListener(this,sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if(accelerometer) { . . } take a look in here: http://developer.android.com/reference/android/content

extract yaw, pitch, and roll from a rotationMatrix

此生再无相见时 提交于 2019-12-02 20:25:56
I have a sensor manager that returns a rotationMatrix based on the devices Magnetometer and Accelerometer. I have been trying to also calculate the yaw pitch and roll of the user's device but am finding that pitch and roll interfere with each other and give inaccurate results. Is there a way to extract YAW PITCH and ROLL of a device from the rotationMatrix ? EDIT Trying to interpret blender's answer below, which i am thankful for but not quite there yet, i am trying to get the angle from a rotaion matrix like this: float R[] = phoneOri.getMatrix(); double rmYaw = Math.atan2(R[4], R[0]); double

Gyroscope Issues with Device Orientation

一笑奈何 提交于 2019-12-02 19:44:56
I'm getting pitch and roll data from my device's gyroscope using this tutorial: http://www.thousand-thoughts.com/2012/03/android-sensor-fusion-tutorial/ All the readings are extremely accurate (there's a filter applied to the code in the tutorial to eliminate gyro drift). Unfortunately, the code only works when my device is placed flat on a surface that is parallel to the ground. The most ideal position for my app to work would be with the top of the device pointing straight up (ie, the device is perpendicular to the ground with the screen facing the user). Whenever I orient my device in this

Detect user activity (running, cycling, driving) using Android

夙愿已清 提交于 2019-12-02 18:24:35
Using my Android device how can I detect if the user is walking, cycling or driving? I have checked the Google Fit app. It differentiates between running, cycling and driving. I am puzzled about what algorithms I should use to differentiate between these activities. I know I would have to use the accelerometer sensor. But still I can't differentiate these activities. You can use the GooglePlayServices for this. It Provides special apis for ActivityRecognition, which returns the User activity with confidence level for each. https://developer.android.com/reference/com/google/android/gms/location