I am using fragments in my project, I am facing one issue in recent android build version 25.2.0
that is clearing fragments not working properly.
Let me explain about my issue.
Initially I have added DbFragmentView() fragment class without adding it on backStack.
getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, new DbFragmentView()).commit();
For all other fragments I am adding it to backstack Using below methond
@Override
public void replaceFragment(Fragment fragment, String Title) {
String backStateName = fragment.getClass().getName();
FragmentManager manager = getSupportFragmentManager();
boolean fragmentPopped = manager.popBackStackImmediate(backStateName, 0);
if (!fragmentPopped) { //fragment not in back stack, create it.
FragmentTransaction ft = manager.beginTransaction();
ft.replace(R.id.frame_container, fragment, fragment.toString());
ft.addToBackStack(backStateName);
ft.commit();
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(Title);
}
}
On some cases I needed to clear all my backstack fragments, for that I am using below code
if (getFragmentManager().getBackStackEntryCount() > 0) {
getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
Everything worked perfectly before changing build version to 25.2.0
.
But After I changing my build version from 25.1.0
to 25.2.0
the above code clearing all my fragments and then it goes back to my first DbFragmentView() fragment but the view is not appearing.
onCreateView
method called but View looks transparent so I can see other app that is in background.
Then I again changed my build version to 25.1.0
then it worked as usual.
Can anyone please tell me the solution to fix this issue
Note : this issue occurred only in latest build version 25.2.0
.