I am writing an app that requires me to track the heading of the user's device. Everything works fine on iOS, but on Android the heading is very unstable and flickers between 2 values very often:
Log output:
angle: 17.43
angle: 358.7
angle: 17.43
angle: 358.7
Here is my code:
onVidLoad(){
Location.watchHeadingAsync(this.onHeadingUpdate).then((v) => {
this.ang_listener = v;
});
}
onHeadingUpdate = (h) => {
var angle = h.trueHeading;
angle -= 180;
angle *= -1;
angle += 180;
console.log("angle:", angle);
}
Thanks in advance.
EDIT: I am using Location.requestForegroundPermissionsAsync every time the app starts, so the problem isn't that I don't have the correct permissions