Hi guys, I am trying to get some good consistent data on one's 
bearings(direction you are facing) either using the LocationListener class 
or the SensorEventListener class. So far I've hit a road block because with 
the LocationListener I dont get consistent data; bearing is almost always 
0. With the sensor listener, the azimuth data is basically 180 ALL THE 
TIME. I've been searching and still am for solutions to this but no luck so 
far. The end goal is to draw a compass on a map in which you can pan around 
and still get back to your location and see the compass; The compass is 
marking your location.

Are there any other options out there or is there a work around for this 
that would be better?

Thanks in advance and here are snippets of some standard code i am using; 
I'm just displaying the data obtained.


Code for LocationListener:

....
manager = (LocationManager) this.getSystemService( Context.LOCATION_SERVICE );
listener = new LocationListener(){

        @Override
        public void onLocationChanged(Location location) {
            txt.setText( "Accuracy : " + location.getAccuracy() + "\n" + 
                    "Altitude : " + location.getAltitude() + "\n" +
                    "Bearing : " + location.getBearing() + "\n" +
                    "Latitude : " + location.getLatitude() + "\n" +
                    "Longitude : " + location.getLongitude() + "\n" +
                        "Provider : " + location.getProvider() + "\n" +
                    "Speed : " + location.getSpeed() + "\n" +
                    "Time : " + location.getTime() );
            }
....

Code for SensorEventListener:

    ....
    manager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    orientation = manager.getDefaultSensor(Sensor.TYPE_ORIENTATION);

    final TextView txt = (TextView) this.findViewById(R.id.txt);

    listener = new SensorEventListener(){

        @Override
        public void onAccuracyChanged(Sensor arg0, int arg1) 
        {

        }

        @Override
        public void onSensorChanged(SensorEvent event) 
        {
            txt.setText( "Azimuth : " + event.values[0] + "\n" +
                    "Pitch : " + event.values[1] + "\n" +
                    "Roll : " + event.values[2] + "\n" +
                    "Accuracy : " + event.accuracy );
        }

    };
    ....

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to