How to get the Android screen orientation (in Java code)

Use this code to get the Android screen orientation:

// orientation (either ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT)
int orientation = getResources().getConfiguration().orientation;

As shown in the comment, the resulting orientation will either be ORIENTATION_LANDSCAPE or ORIENTATION_PORTRAIT. See the Android docs for more information.