android-sensors

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

送分小仙女□ 提交于 2019-12-04 15:28:02
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_DELAY_FASTEST to SENSOR_DELAY_UI) has no effect on the sampling rate and when I add also the magnetic-field

Android Shake(Sensor) Service For shake Detection in Application Background

心已入冬 提交于 2019-12-04 14:57:17
I have develop an Application that have shaking functionality for some function to work so i have use shaking class and implement to Main Activity so its work smoothly while Application running but my question is when my application going to sleep or kill or stop then how to detect shake in background (Service) My shacking class public class Shaker implements SensorListener { private static final int FORCE_THRESHOLD = 350; private static final int TIME_THRESHOLD = 200; private static final int SHAKE_TIMEOUT = 500; private static final int SHAKE_DURATION = 1000; private static final int SHAKE

How to retrieve high quality compass orientation (as in Google Maps)?

天大地大妈咪最大 提交于 2019-12-04 06:43:09
All of the guides to getting compass orientation in Android I've found have a bug: when you hold the phone in portrait mode and "look" above the horizon, the compass arrow turns 180 degrees from the correct direction. Google Maps orientation indicator doesn't have this problem. Another nice thing that Google Maps have is that they somehow estimate compass accuracy. Any idea how they do this? Error you ask is caused because of Euler angles or called Gimbal Lock. To solve very high angle difference, you should check if your device is flat or not checking inclination after getting inclination

How to get the compass direction from azimuth on Android

点点圈 提交于 2019-12-04 06:37:31
I have to display which direction the user is pointing the Android device. I am using Sensor.TYPE_ACCELEROMETER , Sensor.TYPE_MAGNETIC_FIELD to get the azimuth, pitch, roll. But I am to able to figure out how to get directions (North, south, east , west,...) from this. Please help Thanks To point the north you can calculate a rotation in degrees : float rotation = -azimut * 360 / (2 * 3.14159f); You can see the following compass example which make uses of accelerometer and magnetic field : http://www.codingforandroid.com/2011/01/using-orientation-sensors-simple.html Azimuth on Wikipédia : http

Timestamp from Android device in the format hh:mm:ss:SS

大兔子大兔子 提交于 2019-12-04 06:20:20
问题 I have a requirement to log the sensor data in Android. In order to store the values in a Database, I need the timestamp as primary key in the format - hh:mm:ss:SS, where SS represents millisecond value. When I tried to use SensorEvent.timestamp(using the code below), I was unable to get the millisecond from Date class. long currTimeRelativeToBoot = SystemClock.uptimeMillis(); long currTimeAbsolute = System.currentTimeMillis(); double mStartTimeAbsoluteS = ((double)(currTimeAbsolute -

Using TYPE_STEP_COUNTER in a background service?

耗尽温柔 提交于 2019-12-04 06:12:25
I'm looking at implementing the step sensor API introduced in Android 4.4 ( http://youtu.be/yv9jskPvLUc ). However, I am unable to find a clear explanation on what the recommended way to monitor this in the background is? It seems like most examples only show how to do this with an activity while the app is running. I don't particularly need a high frequency of updates - I basically want to log the amount of steps the user has walked every hour to a backend service. Should I just spin up a background service that calls registerListener on SensorManager, or is there a more elegant way? As far

Long running service consumes a lot of battery

老子叫甜甜 提交于 2019-12-04 03:47:48
I developed an app and some people complains that it takes too much battery, it is the second most consuming process after the screen. However, in some devices it does not consumes that much battery. All the work my app do is in a service. The service is sticky and is running all the time (the android system may kill it when has low resources or pause it when device go to sleep), it has listener to the accelerometer as long as the screen is on, it is not foreground service and does not hold wakelock. Can someone tell me why it takes a lot of battery? And why is this happening only on some of

How to detect permission access of other apps?

柔情痞子 提交于 2019-12-03 20:52:46
I'm searching for a way to detect permission usage of other apps. The key idea is to detect, when other apps are accessing media or sensors (e.g. microphone). I want to implement a service, which is looking for any permission usages, so that the service can inform the user, once any app is accessing the microphone or camera. Does anybody know how to do this? I already found out, that I can read all granted permission of an app using the PackageManager, but I'm more interested in "real" permission usage. Thanks in advance! I think detecting permission requests isn't possible in that way. Since

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

早过忘川 提交于 2019-12-03 16:13:05
问题 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. 回答1: Acceleration sensor gives you back the sum of

Android light sensor not triggering event

为君一笑 提交于 2019-12-03 15:47:28
When using the light sensor, I have an issue where the onSensorChanged() event is never triggered. The reason is that when the listener is registered, if the lux value remains constant, there's no change thus no event. However, I still want to know the lux value! There's a difference between a constant lux value of 0, and a constant of 60,000! After some research, I realised that there's no way to directly read the lux value of the sensor. So how do I get the lux value if it's constant, and thus will never trigger an event? Is there a way to set a false value initially (such as -1) so an event