Manifest:
<activity android:name=".MyActivity" android:configChanges="screenSize|orientation|screenLayout|navigation"/>
Activity:
@Override public void onConfigurationChanged(Configuration newConfig) { Log.d("tag", "config changed"); super.onConfigurationChanged(newConfig); int orientation = newConfig.orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) Log.d("tag", "Portrait"); else if (orientation == Configuration.ORIENTATION_LANDSCAPE) Log.d("tag", "Landscape"); else Log.w("tag", "other: " + orientation); .... }
References
https://stackoverflow.com/questions/6896243/how-can-i-detect-screen-rotation