FragmentManager is an interface for interacting with Fragment objects inside an Activity in Android. While the FragmentManager API was introduced in HONEYCOMB, a version of the API at is also available for use on older platforms through FragmentActivity. For more information about using fragments, read the Fragments developer guide.
Questions tagged [fragmentmanager]
700 questions
5
votes
2 answers
fragmentManager.getBackStackEntryCount() does not decrease when removing fragment from manager
The correct behavior I'd like to have is:
Fragment A -> Fragment B -> Fragment C -> Fragment A
What I currently do:
When I want to go back from B to A, I use popBackStack() still here
everything goes well.
When I want to go from B to C I remove B…

Jonathan I
- 240
- 1
- 4
- 18
5
votes
1 answer
FragmentManager is already executing transactions on commitAllowingStateLoss()
java.lang.IllegalStateException: FragmentManager is already executing transactions
I've read all StackOverflow questions about that, and nothing helped.
Just wanted to share my experience
public void onResume() {
super.onResume()
…

StepanM
- 4,222
- 1
- 21
- 25
5
votes
2 answers
Fragment is not visible after popbackstack
I add fragment (home fragment) in Activity.onCreate(), without adding it to backstack, I do it using FragmentTransaction.replace(). After that i add every next fragment using FragmentTransaction.replace() and adding it to backstack.
I have a…

FullRandom
- 71
- 7
5
votes
2 answers
Detect user inactivity in DialogFragment and logout after some time
There are many activities and dialog fragments in my app. I searched about detecting activity and came to know about onUserInterAction function but it detects in activity for activities only but not while a dialog fragment is open.

Hafiz Fahad Munir
- 507
- 4
- 17
5
votes
2 answers
How can I access getSupportFragmentManager() in a static method?
In my application I have two activities both having a static method. I call these methods from a separate activity. The problem is that in my static methods I am unable to get access to getSupportFragmentManager(); the error being produced…

baldraider
- 1,049
- 2
- 18
- 48
5
votes
2 answers
Get Fragment instance in Activity
I have added Fragment to Activity like
getSupportFragmentManager().beginTransaction()
.add(R.id.container,new MyFragment).commit();
where container is the id of FrameLayout

Zar E Ahmer
- 33,936
- 20
- 234
- 300
5
votes
0 answers
Fragment Shared Element Transitions FragmentManager with add() not working
When I tried to use transitions with fragments using similar code from this article on Medium GitHub. It wouldn't work when I am using the add method() on fragment manager but it would work with replace().
FragmentManager fragmentManager =…

pt123
- 2,146
- 1
- 32
- 57
5
votes
2 answers
Does a retained Fragment retain its View?
Calling Fragment.setRetainInstance(true) will cause the Fragment to be retained by the FragmentManager, but is it's View retained? I think not, but I'm looking for confirmation. I think not because Fragment.onCreateView() is still called (even…

Barry Fruitman
- 12,316
- 13
- 72
- 135
5
votes
2 answers
App force close on viewPager.setAdapter(adapter)
I have an application page with viewpager containing two fragments.
When my activity pops up , a server request is made for loading current data and then adapter is set.
But the app crashes with the following error.
Attempt to invoke virtual method…

user2781627
- 455
- 5
- 17
5
votes
0 answers
Save state of fragments in backstack
My problem is generally described in this question:
Once for all, how to correctly save instance state of Fragments in back stack?
But i can't understand how the accepted answer is related to it.
To keep it short:
There are 2 fragments A and B.
I…

user2203031
- 402
- 3
- 14
5
votes
1 answer
Pop back stack without onresume called
I got activity a. then I put b in backsatck and display it;
I want to call c such that a not called again however I want to pop B from BackStack such that return back from C I want it returns to A.
Here is the scenario:
A->B
C Called: A->C
C closed…

VSB
- 9,825
- 16
- 72
- 145
5
votes
1 answer
java.lang.IllegalStateException(Can not perform this action after onSaveInstanceState)
I am getting this error with following message in different scenario:
Activity has been destroyed and
Can not perform this action after onSaveInstanceState
I am writing an app where Two Activity interacting with each Other. Activity-A launch…

CoDe
- 11,056
- 14
- 90
- 197
5
votes
3 answers
android -does calling finish from activity destroy hosted fragment?
I have an 'Activity A' which host a 'Fragment B'. Please confirm that if I call A.finish() then 'fragment B 'gets destroyed. The fragment B would already be added to the fragment manager. I realize that a fragment is a sub-activity but i want to…

j2emanue
- 60,549
- 65
- 286
- 456
5
votes
0 answers
FragmentManager replace fragments without calling onPause() onDestroy() for the old fragment
In my application, I have a left menu that controls Fragment transactions in one FragmentView in my MainActivity. Above the FragmentView I have the new PullToRefresh component that is used in the new GMAIL only being refreshed in only one Fragment.…

Sami Eltamawy
- 9,874
- 8
- 48
- 66
5
votes
2 answers
FragmentManager from application context
Is there a way to get FragmentManager from application context? I want to use ImageLoader or BitmapFun to store some bitmaps that I download from server. Both class require a FragmentManager to use to retain the cache over configuration changes such…

learner
- 11,490
- 26
- 97
- 169