Covers how and when the lifecycle callback methods like onAttach, onCreateView etc. are being called when the fragment is created, destroyed, recreated or put in the backStack.
Questions tagged [fragment-lifecycle]
150 questions
0
votes
1 answer
When can I use GoogleMap.getProjection().getVisibleRegion()?
I have to get GoogleMap.getProjection().getVisibleRegion().latLngBounds
But when app is started, its values are all zero.
I tried to get this at onViewCreated, onActivityCreated and onStart of SupportMapFragment, but it doesn't work. When I can do…

Gimun Eom
- 411
- 5
- 17
0
votes
0 answers
DialogFragment dismisses itself after orientation change
A similar question has been asked before, but my case is different.
I have DialogFragments all over my app. When I rotate the phone, all of the DialogFragments come back without issue except this one.
I've littered the life cycle callbacks with Log…

Tunji_D
- 3,677
- 3
- 27
- 35
0
votes
1 answer
Fragment lifecycle error in 4.4, onCreateView() is called on multiple fragments same time
I am getting error :
In error, Android framework is calling onCreateView() of multiple fragment at the same time
I have Navigation Drawer with 3 FrameLayout : A, B , C
1.) Through B Option of drawer, User reached to B2 Fragment.
2.)User presses…

Kushal
- 8,100
- 9
- 63
- 82
0
votes
2 answers
Fragment not added to activity when method is called
I have a main activity called Chessboard. Within Chessboard, in the onCreate, I set a fragment activity GameInfoFragment. After this, a call is made to query an SQLite database, immediately after which a method in class SQLiteDataInterpreter is…

credo56
- 423
- 1
- 8
- 19
0
votes
0 answers
How to call a fragment inside another fragment without reloading the fragment in android?
I have used two fragments in my application to show the list and detail view. When I press the list fragment it should show the detail view fragment and when I press back it should the list fragment. This flow is working fine but the problem is,it…

Loganathan
- 1,864
- 3
- 12
- 17
0
votes
0 answers
fragments in viewpager get recycled and not reloaded
I have fragments in a viewpager. The viewpager loads the fragments one index forward and one index behind the current index.
The user can scroll past the viewpager, and this uses more memory as other image objects are processed in other parts of the…

CQM
- 42,592
- 75
- 224
- 366
0
votes
0 answers
Reference to a Fragment after the life cycle has complete and restarted
I am trying to activate a runnable after 90 seconds. But if the user leaves the fragment and comes back, when the timer hit, it crashes.
Here is what I have so far.
when they click the button:
Handler handler = new Handler();
handler.postDelayed(new…

DDukesterman
- 1,391
- 5
- 24
- 42
0
votes
1 answer
Fragments in a ViewPager – Tapping a button inside current frag effects the fragment after it NOT the current/visible frag
Problem: Upon clicking a button in a fragment inside of the ViewPager the click falls through to the fragment that is behind it and registers the onClickListener() in the behind fragment rather than the current fragment’s…

Sakiboy
- 7,252
- 7
- 52
- 69
0
votes
1 answer
android fragment isRemoved method
There is a isRemoving method for fragments in android. Per the documentation, it only tells when a fragment is in the process of being removed. But I need to know whether a fragment has already been removed. Is there a way to find this out? I am…

learner
- 11,490
- 26
- 97
- 169
0
votes
2 answers
Lifecycle of fragments when user "quits"
I have a main activity which is showing/hiding a bunch of fragments. There is a login activity at the very start that logs the user in. When the user presses home or the multi-tasking button, the app should start a timer that (after the timer runs…

John Baum
- 3,183
- 11
- 42
- 90
-1
votes
1 answer
How to manage to start fragment `onCreateView()` after data is loaded form the internet
I have 3 Fragments inside a ViewPager. I call an API in onCreate() of the first Fragment which returns JSON data (second and third Fragments are empty).
The problem is that onCreateView() is always executed before getting data from API, so I need to…

Mehrdad Salimi
- 1,400
- 4
- 16
- 31
-1
votes
1 answer
I am not able to figure out how to pass Bundle in mapview.onCreate() in custom viewholder class
i have a generic viewholder class for recyclerview which uses MapView inside that row, and the viewholder class is extending my base viewholder abstract class which has populateData(TO to), i am initializing map in the constructor of my viewholder…

kuldeep zala
- 57
- 3
- 12
-1
votes
1 answer
What event of Fragment will be called when I click device back?
I am adding a fragment B on top of another fragment A as follows:
fragmentManager.beginTransaction().add(R.id.frame_container, fragment).addToBackStack("post_details").commit();
The issue is, when I click on device back on B, I need an anchor in…

pagalpanda
- 150
- 2
- 16
-3
votes
3 answers
Where to put "ViewPager.setCurrentItem()" Method
I have Nested Fragments [1 main Fragment called "MainFrag" and many child Fragments]
the App can show MainFrag or can show other fragments.
what I want to do is to setCurrentItem of MainFrag's ViewPager every time the user selects to show that…

Atef Hares
- 4,715
- 3
- 29
- 61
-3
votes
1 answer
What exactly onCreate() method will do in a Fragment Life Cycle in an Android Application
I am confusing onCreate() method in both Activity and Fragment. What onCreate() will do in Fragment and What are differences onCreate() method between Activity and Fragment.Please help me i am learning by myself.
Thanks......

Narasimha Rao
- 37
- 1
- 4