protected static String getOrientation ( Context ctx ) { try { String o ; switch ( ctx . getResources ( ) . getConfiguration ( ) . orientation ) { case android . content . res . Configuration . ORIENTATION_LANDSCAPE : o = "landscape" ; break ; case android . content . res . Configuration . ORIENTATION_PORTRAIT : o = "portrait" ; break ; default : o = null ; break ; } return o ; } catch ( Exception e ) { Log . e ( TAG , "Error getting device orientation." , e ) ; return null ; } }
Get the device s current screen orientation .