I am testing situation where a user goes into my app after the system has terminated the app process due to low RAM. I am seeing unexpected behavior and hoping to get some help
When you call super.onCreate()
, Fragments automatically restore their current state when savedInstanceState
is not null.
Therefore if you're expecting to do one time set up by adding your intial Fragment, you should always surround it with an if (savedInstanceState == null)
check:
@Override
public void onCreate(Bundle savedInstanceState)
{
// I assume you accidentally left out these lines
super.onCreate(savedInstanceState);
setContentView(R.id.your_content_view);
if (savedInstanceState == null) {
FragmentA fragA = new FragmentA();
FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransation.replace(R.id.basic_frame, fragA);
fragmentTransaction.commit();
}
}