How are Android sensor TYPE_LINEAR_ACCELERATION and TYPE_ROTATION_VECTOR implemented?
Is the source code available somewhere?
Unfortunately, the Fused Location Provider API is not a part of the Android Open Source Project but rather it's implemented as a part of Google Play Services which is a proprietary Google software and it's source code is not publicly available. In fact, the FusedLocationProviderApi.java
interface implementations are purposedly obfuscated, for example:
public class zzd implements FusedLocationProviderApi {
public zzd() {
}
public Location getLastLocation(GoogleApiClient var1) {
zzl var2 = LocationServices.zzj(var1);
try {
return var2.getLastLocation();
} catch (Exception var4) {
return null;
}
}
...
How have they been implemented?
Since the source is not available, we may only speculate on how exactly it's implemented.
Android Sensor.TYPE_LINEAR_ACCELERATION reporting wrong values on Galaxy S5
=== New answer ===
I have seen that a change the sampling rate of the sensor did the trick in avoiding this error. From the probable SensorManager.SENSOR_DELAY_FASTEST
to SensorManager.SENSOR_DELAY_UI
=== Old Answer ===
Given my 2 comments on your question and because of having the same problem on 2 other Galaxy 5S', at the present moment, and with regard to the goal which is detecting the telephone's stillness, I can only suggest 2 workarounds: a peak-to-peak value consideration, and a high pass filter.
- Peak-to-peak Value Consideration: just measure the difference between the last 2 readings; if this is bigger than a threshold then a movement event can be triggered.
- High Pass Filter: slightly more complicated, but more professional, implement in your code such a filter that will only bring forward rapid changes in the acceleration, while suppressing the constant value of 19.
TYPE_LINEAR_ACCELERATION and TYPE_GRAVITY not working
OK, by applying the first rule of engineering and general common sense the problem was solved :) Just turned it off and on again, and now it automagically works. This is a bit troubling though, because it means I have no way of knowing if the sensors are working properly other than using a timeout thread to verify periodic updates.
Related Topics
Causing Outofmemoryerror in Frame by Frame Animation in Android
How to Draw a Route, Along an Existing Road, Between Two Points
Cancel Notification on Remove Application from Multitask Panel
Android Launching Music Player Using Intent
How to Parse This Nested JSON Array in Android
What Does Ellipsize Mean in Android
Handle Button Click Inside a Row in Recyclerview
Android - Best and Safe Way to Stop Thread
A Failure Occurred While Executing Com.Android.Build.Gradle.Internal.Tasks
Getting the Battery Current Values for the Android Phone
What's Wrong with Debugging in Eclipse on Android
How to Run an Android App in Background
Gradle Dsl Method Not Found: 'Compile()'
How to Disable Instant Run for Android Studio 3.0
Load Dimension Value from Res/Values/Dimension.Xml from Source Code