0

The minSDK in my app is 16.

I use Fragments and read a lot about the difference between android.app.Fragment and android.support.v4.app.Fragment. The explanation in most answers was, that if I will support devices below 11, I have to use the support libraries. My minSDK is 16, so I decided to use android.app libraries for all my Fragments and FragmentManagers.

Now I need nestedFragments and for that I need getChildFragmentManager() in a DialogFragment... getChildFragmentManager on native Fragment library requires api 17. The solution on similar questions is to use to use the fragments backport from the support-v4 of the Android Support package.

I'm confused. Do I have to change all used Fragments and FragmentManager in my app to the support package? What about the recommendation to use support packages only on minSDKs below 11? Can anyone please explain it?

Thanks a lot!

Raspberry
  • 139
  • 1
  • 11

2 Answers2

1

There is no recommendation that you only use the support library for min SDK < 11. You are required to use it if you want to use Fragments on devices running < 11 because that is when the Fragment API was introduced. However, as you have discovered, the support library also provides backwards compatibility for other APIs introduced in much later versions of Android.

Most developers will recommend that you always use the support library for application components such as Activities and Fragments (along with notifications and most other features the support library offers) because you get all the newest APIs and features, plus you get fewer bugs because the Android team cannot fix bugs in already-released platforms.

Behind the scenes the support library will leverage the platform classes when it can, so you don't need to worry about picking between the two.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
1

Yes you need to do any one of these

  1. Use support library to use getChildFragmentManager() provided dialog is also from support library.
  2. Use android.app library and change the api level to 17.

Also, this link is useful

ADM
  • 20,406
  • 11
  • 52
  • 83
Thriveni
  • 742
  • 9
  • 11