Orientation sensor problem.

by Cardy » Wed, 02 Jun 2010 07:14:45 GMT


Sponsored Links
 Hi all!

I've been trying to get a simple test app working to show me the
orientation of the phone. The code I've used is below:

public class Main extends Activity implements SensorEventListener {

        SensorEventListener listener;
        TextView mainText;
        SensorManager sensorMan;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        mainText = (TextView)this.findViewById(R.id.mainString);

        sensorMan =
(SensorManager)this.getSystemService(Context.SENSOR_SERVICE);
        sensorMan.registerListener(
           this,
           sensorMan.getDefaultSensor(
              SensorManager.SENSOR_ORIENTATION),
           SensorManager.SENSOR_DELAY_NORMAL);
    }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
                // TODO Auto-generated method stub

        }

        @Override
        public void onSensorChanged(SensorEvent event) {

                float[] values = event.values;
            mainText.setText(
                                "AngleX: "+ values[0]  +
                                "AngleY: "+ values[1] +
                                "AngleZ: "+ values[2] );
        }
}

So from what I've seen everywhere, the angles should range somewhere
between -360 to 360 or -180 to 180. Something like that anyway. But
what I'm receiving when testing on my T-Mobile G2 is completely
different:

AngleX: -10 to 10
AngleY: -10 to 10
AngleZ: -11 to 11

Initially I assumed this was radians but it's outside of -PI to PI
(i.e. it'd be > 360 degrees which is contrary to all the blog posts
I've seen.

If anyone else has heard of this or seen this problem I'd love to know
what you did!

Any information or ideas are welcome!

Thanks a lot!

Andy.

--



Orientation sensor problem.

by ThomasWrobel » Wed, 16 Jun 2010 04:42:29 GMT


 Did you ever get to the bottom of this?
I think I'm having a similar problem.




--


Sponsored Links


Other Threads

1. How to know the mac address of the device?

Hello frnds,

I would like to the mac address of the device programmatically.

Can any one please help me how to get it programmatically?

thanks,
Manoj.
--~--~---------~--~----~------------~-------~--~----~

2. Market stats mystery

Starting this past weekend, all of a sudden the Android Market stats
for new Active Users for my app has dropped VERY sharply while the new
downloads are higher than usual. (This is usually a symptom of large
numbers of existing users re-downloading and re-installing the app)
The user comments are positive as ever, the rating remains high at 4
stars, and emails to me the developer also remain positive. I have
retested my app on RC33 and it works fine. I'm confused, and
apparently with no recourse to really get in touch with someone at
Google to understand what is really going on.

I am suspecting that with the new Android Update RC33 something has
changed with the way these download and new user numbers are captured,
calculated or reported.

Anyone else experiencing anything similar with their stats?
thx
Jay
--~--~---------~--~----~------------~-------~--~----~

3. problem in playing mediaplayer

4. i.MX31 Touch screen co-ordinate transformation problem

5. Communicating with a Looper thread

6. Problem in going back activity

7. Is this going to take away a G1 selling point?