Reputation: 447
We have an app which has minimum SDK level set to API 21. We are currently using support fragments and are now discussing migrating to native fragments.
This discussion of the move towards native fragment is because support fragment is meant for lower API devices which don't support native fragments. Now that every device has fragment and they seem stable. So why not migrate to native fragments for leaner implementation.
New features will hopefully be supported for native fragments with support library v13's FragmentCompat, things like ViewPager are already present in support library v13. But platform specific bugs will require API specific handling.
On the other hand with support library v4's Fragment we get
Backward compatibility with features e.g. runtime permissions.
Consistency across all the platforms as it uses the same implementation across platforms. No platform specific handling.
All new methods in next android version are available to use across all the platform.
Support library is released more frequently than Android platforms. So bug fixes will be faster and we'll have more control when pushing that fix. Don't need to wait for OEMs to update each phone but rather update the support library in the app.
But are these benefit enough to hang on to the old code which is meant for devices with API level less than 11?
Upvotes: 3
Views: 874
Reputation: 38223
This should help you decide as it's now the official Android Team stance:
Fragment
This class was deprecated in API level P.
Use the Support Library
Fragment
for consistent behavior across all devices and access to Lifecycle.
Source: https://developer.android.com/reference/android/app/Fragment
But are these benefit enough [...]?
Absolutely, you want the consistent behavior without having to cater to each API level and vendor specific quirks.
Upvotes: 2