Check out this snippet : Activity.class
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    if(getWindowManager().getDefaultDisplay().getRotation() == Surface.ROTATION_0){
        // clockwise
    }else if(getWindowManager().getDefaultDisplay().getRotation() == Surface.ROTATION_180){
        // anti-clockwise
    }
} else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
    //portrait
}
Not just to check at the start, but you should also check that if it's getting changed in runtime too.
AndroidManifest.xml
<activity
    android:name=".MainActivity"
    android:configChanges="orientation"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar">
MainActivity.java
@Override
public void onConfigurationChanged(Configuration newConfig) {
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        //landscape
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        //portrait
    }
}