Top "Fragment-lifecycle" questions

Difference and uses of onCreate(), onCreateView() and onActivityCreated() in fragments

What are the differences between onCreate(), onCreateView(), and onActivityCreated() in fragments and what would they each be used for?

android android-fragments android-lifecycle oncreate fragment-lifecycle
Why getContext() in fragment sometimes returns null?

Why getContext() sometimes returns null? I pass context to LastNewsRVAdapter.java as an argument. But LayoutInflater.from(context) sometimes crashes. …

android android-fragments fragment-lifecycle
Restoring MapView's state on rotate and on back

Background I have a larger application in which I had/have several problems with new Google Maps API. I tried …

android android-fragments android-mapview android-maps-v2 fragment-lifecycle
Understanding Fragment's lifeCycle methods calls during fragment transaction

I created a demo to understand which all fragment lifecycle's methods are called during different cases of fragment transaction.While …

android android-fragments fragment-lifecycle
Stop handler after the fragment has been destroyed

I have a Fragment which sets up a ListView and creates a Handler to update the Listview periodically. However, it …

android listview android-fragments android-lifecycle fragment-lifecycle
Difference between add() & replace() with Fragment's lifecycle

My program has 6 fragments: Fragment1, Fragment2,....->Fragment6. I use the add() and replace() statement to switch between the …

android android-fragments fragment-lifecycle
Where to restore fragment state that is inside ViewPager

Short Version: I have an Activity that has a ViewPager. The ViewPager has three fragments inside it. I am storing …

android android-fragments android-viewpager fragment-lifecycle
IllegalArgumentException with Otto Event bus in Fragment instance

I am using Otto Event bus to subscribe to certain events in a ListFragment. The bus instance is stored and …

android android-fragments activity-lifecycle otto fragment-lifecycle
Fragment lifecycle events in LifeCycleAware Fragment

I have a lifecycle aware fragment and a LifecycleObserver class public class MyFragment extends Fragment { @Override public void onCreate(@Nullable …

android android-fragments android-lifecycle fragment-lifecycle