AppCompat v7: Should I be using Framework FragmentManager or SupportFragmentManager?

I am creating an application that needs to have minSdk = 15 and targetSdk = 21, so I want to use the functions provided by the appcompat-v7 library.

I've always wondered if I should use getFragmentManager or getSupportFragmentManager when using supportlibrary-v7.

Now I am facing a little problem: when using getFragmentManager (and thus using the framework and fragmentation frameworks) I was unable to pull the back by simply clicking on the stand - I had to do backStackCount> 0 check and manually popBackStack, otherwise my activity was just finished. This issue was resolved when I switched my little app to use v4 classes (getSupportFragmentManager, etc.). I think this is good, but I would like to have a guide / bestpractice to learn how to go and why

So my Activity inherits from ActionBarActivity (as per AppCompat-Blog-Entry ) and I'm using the new toolbar, should I only use v4-Fragments (-Manager, -Transactions)?

I have not found any recommendations or recommendations for this. And I'm not sure what to consider when choosing between these two: - /

+3


source to share


1 answer


If you inherit your actions from ActionBarActivity

, you should always use getSupportFragmentManager()

. It will automatically redirect your calls to getFragmentManager()

if the phone supports it (cell is running or later), otherwise it uses its compatibility implementation.



+5


source







All Articles