Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Device (GPS) Direction

Tags:

android

Using Location.getBearing(); I seem to get randomly changing bearings.

Aka, I can turn the device around slowly and it wont notice, it just chooses its own random bearings.

I know the device is working, as the "You are here" icon in the Maps app on the tablet slowly rotates as I rotate the device.

Is there a different proper way of getting bearing? I am using the GPS. Maybe there is a better way to determine which direction you are facing.

like image 368
IAmGroot Avatar asked Jul 04 '12 14:07

IAmGroot


2 Answers

Try to get bearing from Accelerometer sensor and Magnetic Field (G-) sensor.

Here's a tutorial: http://android-coding.blogspot.co.at/2012/03/create-our-android-compass.html

like image 191
herom Avatar answered Oct 21 '22 02:10

herom


The Location.getBearing() returns the bearing that the GPS satellites computed for you. It is not a real time representation of the heading of your device. The Google Maps app uses the device's built in G-sensors to get the direction you are facing.

like image 20
Adam Monos Avatar answered Oct 21 '22 02:10

Adam Monos