i have a listFragment this is my onActivityCreated:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
utenti=savedInstanceState.getParcelableArrayList("array");
}else{
threadutenti= (GetUtenti) new GetUtenti(this.getActivity(), utenti).execute();
}
When i rotate my device i have first savedInstanceState non null (i got it) but after onActivityCreated is called with onActivityCreated null!! why? i want get my object utenti on ListFragment and not on my activity..
Both onCreate and onCreateView get called every time I get to a tab.
OnCreateView is called twice without pressing back button or on any other event. Its called twice, once when fragment initially creates and again just after findNavController. navigate event.
This can happen if you're always creating a new fragment in your Activity#onCreate()
callback.
If it's true, check this answer. Your Fragment#onActivityCreated
will be called twice:
FragmentActivity#onStart
's call to mFragments.dispatchActivityCreated()
. It will pass the saved instance.FragmentActivity#onStart
's call to mFragments.execPendingActions()
. This time without saved instance (since it is being called in response to new Fragment addition).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With