Get the orientation of the phone
(Android phone – how-to/example)
If your application is dependent on the orientation of the phone, you may like to take a look at android.view.OrientationEventListener package.
To create the OrientationListener you will need the current activity Context.
private void CreateOrientationListener(Context context)
{
m_OEListener = new OrientationEventListener (context, SensorManager.SENSOR_DELAY_UI)
{
public void onOrientationChanged (int orientation)
{
// in orientation you will find the orientation expressed in degrees
To enable/disable the listener:
public void OrientationEnable(boolean enable)
{
if (m_OEListener==null)
return;
if (enable)
m_OEListener.enable();
else
m_OEListener.disable();
}
Note: You may choose to enable/disable while pausing/resuming the current activity.












