Hi make use of sensorListener and it will work ......... i have used the same .......... when u use sensorlistener and sensormanager in ur view it has got an override method as onSizeChanged which return the width and height......... so using change in size u will get the orientation
Below is a code for u of orientation check ......... enjoy : import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.hardware.SensorManager; import android.hardware.SensorListener; import android.util.Log; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.RectF; public class Midlet extends Activity { /** Tag string for our debug logs */ private static final String TAG = "Sensors"; private SensorManager mSensorManager; private GraphView mGraphView; private class GraphView extends View implements SensorListener { public GraphView(Context context) { super(context); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { System.out.println("on sizechanged"); super.onSizeChanged(w, h, oldw, oldh); } @Override protected void onDraw(Canvas canvas) { } public void onSensorChanged(int sensor, float[] values) { } public void onAccuracyChanged(int sensor, int accuracy) { // TODO Auto-generated method stub } } /** * Initialization of the Activity after it is first created. Must at least * call {...@link android.app.Activity#setContentView setContentView()} to * describe what is to be displayed in the screen. */ @Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mGraphView = new GraphView(this); setContentView(mGraphView); } @Override protected void onResume() { super.onResume(); mSensorManager.registerListener(mGraphView, SensorManager.SENSOR_ACCELEROMETER | SensorManager.SENSOR_MAGNETIC_FIELD | SensorManager.SENSOR_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST); } @Override protected void onStop() { mSensorManager.unregisterListener(mGraphView); super.onStop(); } } On Wed, Mar 25, 2009 at 11:26 AM, Suman <ipeg.stud...@gmail.com> wrote: > > Hi.... > > > > Many thanks for replies. I actually want to do > something if the screen orientation is landscap. Am trying something > like this............... > > if(getRequestedOrientation()== landscap) > { > > { > > But it was not working. So if the way is correct then please tell > me > if(getRequestedOrientation()== ????) > > Or suggest something another way. > 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---