kalyan simhan wrote:
> hi all..
> im trying to change the orientation of my screen dynamically as the user
> changes the position of the phone i.e from portrait to landscape..im
> trying to
> do this on a openmoko freerunner.. im doing it this way..
>
> sensorMgr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
> sensorListen = new SensorListener() {
>
> @Override
> public void onAccuracyChanged(int sensor, int accuracy) {
> }
>
> @Override
> public void onSensorChanged(int sensor, float[] values) {
>
> x.setText("x=" + values[0]);
> y.setText("y=" + values[1]);
> z.setText("z=" + values[2]);
> setContentView(linear); // linear is a LinearLayout
> containing 3 textviews
> if (sensor == SensorManager.SENSOR_ORIENTATION) {
> // check the values array and change orientation
> }
> }
> };
> sensorMgr.registerListener(sensorListen,
> SensorManager.SENSOR_ORIENTATION);
>
> }
>
> I dont get any values for x,y,z... why is it.. am i doing it the right
> way.. please please help!
> Thanks in advance!
If this is just an ordinary screen, use
android:screenOrientation="sensor" in your manifest:
http://androidguys.com/?p=2914
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
_Beginning Android_ from Apress Now Available!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---