Using a HTC Magic. (Android 1.6)
Am a beginner.  Have gone through the documentations available. I know
I might be asking a silly question.
I am trying to continuously read and assign the lat/long and
orientation values into variables.  I am able to do them as separate
programs using the sample codes available.

I tried to implement this using the code I found here:
http://blogs.eteration.com/blog/?p=887

And replaced the 'Accelerometer' with 'Orientation'.

TYPE_ORIENTATION should be replaced with
SensorManager.getOrientation() for the newer APIs.  So Is there a way
I can integrate that changes?

public class abc extends Activity implements LocationListener,
SensorEventListener{
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                       //bind the ui components to code referances
                       latitude = (TextView) findViewById(R.id.latitude);
                        longitude = (TextView) findViewById(R.id.longitude);
                        //get the locationManager
                        locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
                        startListening();

             //Sensor Manager
           sensorManager = (SensorManager)
getSystemService(Context.SENSOR_SERVICE);

            //Compass
                        sensorManager.registerListener(this,
sensorManager.getSensorList(Sensor.TYPE_ORIENTATION).get(0),
100);
            }

..
..
public void onSensorChanged(SensorEvent event) {
            // TODO Auto-generated method stub
                //if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) {
                if (event.values[0] >= 0) {
                myazimuth = event.values[0];
                mypitch = event.values[1];
                myroll = event.values[2];
                azimuth.setText(event.values[0]+"");
            pitch.setText(event.values[1]+"");
            roll.setText(event.values[2]+"");
                startListening();

                }
         }
________________________________________________________________________________

Is the the right way of doing it?
It just doesn't seem to work.
I don't want to display these values(although am currently doing that
to check if I am getting results) but I want 5 variable to store the
values of La/long and the orientation sensors. I want them available
at all times in the program so that I use them for performing some
computations in other methods.

Please advice if there is  better way of doing it.

Thanks in advance

-- 
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