Reputation: 11790
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 as an orientation change. In my case I want to pre-download the images before I actually "need" them.
Upvotes: 6
Views: 7698
Reputation: 1684
Yes, you can.
First you have to read this solution to get the "Current activity" of your application:
How to get current foreground activity context in android?
Activity activity = ((MyApplication) getApplicationContext()).getCurrentActivity();
FragmentManager fragmentManager = activity.getFragmentManager();
Upvotes: 3
Reputation: 1007228
Is there a way to get FragmentManager from application context?
No, because fragments are part of an activity.
In my case I want to pre-download the images before I actually "need" them.
Then use a different library, one that does not have a dependency upon fragments.
Upvotes: 4