android-sensors

Detect if device has taken a turn using location service android

邮差的信 提交于 2019-12-10 11:54:35
问题 I want to detect if the user has taken a turn on the road while driving using the sensors on the android phone. How do I code this? I am collecting data live from all the sensors(accelerometer,location,rotation,geomagnetic) and storing them on the sd card. So now i just want to know whether the user has a taken a turn and in which direction he has turned. 回答1: I assume the registration of the sensor is done properly. You can detect the direction by using the orientation sensor (deprecated) as

How can i get device tilt?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 11:43:33
问题 I am trying to get device tilt (device rotation along y-axis but unfortunately i am unable to achieve my goal. I have tried a lot of stuff using TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD as a combined sensor (Sensor fusion). i have also followed Motion Sensors What i want? i want to get inclination of device (cell phone ) attached in a vehicle. Let say, i attached a device in a car and car is stationary. So inclination is 0 degrees.Lator on, when vehicle pass through under passes or flyovers

Android Sensor.TYPE_ORIENTATION works perfect and I can't get the same results with accelerometer and magnetometer

爱⌒轻易说出口 提交于 2019-12-10 11:28:25
问题 I am trying to use this non-deprecated version of code to get orientation. However I can't get it to work as smooth and perfect as if I just use the deprecated Sensor.TYPE_ORIENTATION. Am I missing something? //OLD @Override public void onSensorChanged(SensorEvent arg0) { m_lastYaw = arg0.values[0]; invalidate(); } //NEW @Override public void onSensorChanged(SensorEvent event) { if (event.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE){ return; } if (event.sensor.getType() == Sensor.TYPE

How to enable proximity sensor in android

筅森魡賤 提交于 2019-12-10 11:04:22
问题 I have configured proximeter successfully in my code. Now I want to turn off & on screen programmatically. Code of sensor is working just fine and following method is also getting called. @Override public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLock screenWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"screenWakeLock"); if (event.values[0] == 0) { screenWakeLock.acquire

Android rotation vector sensor error [closed]

白昼怎懂夜的黑 提交于 2019-12-10 09:27:12
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I'm not asking a question. I'm going to post this in case anyone else runs into this problem. If you follow the Android API guide for the rotation sensor, you will run into an error. Specifically: java.lang.IllegalArgumentException, because some devices return an array with FIVE values. You can

Galaxy Nexus: Sensor Sampling Rate becomes faster when sampling more Sensors

痴心易碎 提交于 2019-12-09 22:50:15
问题 I'm trying to read out sensor values as fast as possible from a Samsung Galaxy Nexus (with Android 4.0). For this I did a few experiments using different sensors and sampling rates and figured out a very weird behaviour. When I use only the Acc-Sensor the sampling-rate is about 50Hz. But when I also use the Gyro-Sensor (or magnetic-field-sensor) the sample-rate of the Acc-Sensor increases and both have a sample-rate of between 90 and 100 Hz. A change of the sensor-delay (e.g. from SENSOR

Compass direction is different depending on phone orientation

a 夏天 提交于 2019-12-09 17:58:29
问题 My augmented reality app needs the compass bearing of the camera view, and there's plenty of examples of getting the direction from the sensormanager. However I'm finding the resulting value different depending on the phone orientation - landscape rotated to right is about 10 degrees different to landscape rotated to left (difference between ROTATION_0 and ROTATION_180 is less, but still different). This difference is enough to ruin any AR effect. Is it something to do with calibration? (I'm

How to control Android proximity sensor?

六眼飞鱼酱① 提交于 2019-12-09 09:23:29
问题 Can someone provide an example as to how to use the proximity sensor? Please describe some event and how to use them. 回答1: Every android mobile is shipped with sensors to measure various environmental conditions.Proximity sensor measures the distance that some object is from the device. It is often used to detect the presence of a person’s face next to the device. Some proximity sensors only support a binary near or far measurement. In this case, the sensor should report its maximum range

Android: Amplitude value to Decibel value?

杀马特。学长 韩版系。学妹 提交于 2019-12-09 06:44:38
问题 I'm trying to get the decibel of noise being recored from mic on Android phone. I can get amplitude value and looking for the formula to convert it into decibel. I use following function of MediaRecorder to get amplitude. mediaRecorder.getMaxAmplitude() ; In another question I found the following formula. power_db = 20 * log10(amp / amp_ref); amp is amplitude but not sure what's amp_ref . Is there anyone knows the correct formula? 回答1: i think that is the correct formula. amp_ref is reference

Inconsistent orientation sensor values on Android for azimuth/yaw and roll

烂漫一生 提交于 2019-12-09 06:24:23
问题 I’m having trouble getting good orientation sensor readings. The sensor readings seemed unreliable, so I tested my code against two free sensor test apps (Sensor Tester (Dicotomica) and Sensor Monitoring (R's Software)). I found that while my readings often agreed with the sensor test apps, occasionally the values for azimuth/yaw, and roll differed by up to 40 degrees, although the pitch reading mostly agreed. The two free apps always seemed to agree with each other. I put my code into a tiny