In Handling runtime changes in the Android documentation explains a little the process you must follow to control orientation or configuration changes.
For your case with Fragments I think that in the documentation link is very well explained how to manage this process. Manage it using setRetainInstance(boolean)
One way to control screen turns in the Activity is as follows:
In the manifest you declare the changes that you want to control by means of the android:configChanges
tag, leaving the declaration of the activity in the following way:
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize"
android:label="@string/app_name"
android:theme="@style/AppThemeAction" />
And then the code that is put in the activity to pick up the configuration change events such as the change of orientation of the screen is as follows:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//detectamos el cambio de orientación en este caso
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
landscape = true;
//acciones deseadas
}
if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
landscape = false;
//acciones deseadas
}
}