Disable Other Fragments In Auto Rotation
i have an app with various fragments and the problem is when the phone rotates, the app displays other fragments from the begining. it does not close the current fragments but look
Solution 1:
Try this to add in your AndroidManifest
<Activity
....
....
android:configChanges="orientation|screenSize">
Solution 2:
You need to check for a savedInstanceState, and if it exists, don't re-create your fragments. just check if is null or not
as shown below
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if (savedInstanceState == null) {
// Do your oncreate because there is no bundle
}else{
// Do that needs to be done even if there is a saved instance, or do nothing
}
}
check this for more detail.
Post a Comment for "Disable Other Fragments In Auto Rotation"