I'm implementing fragments in my app. In order to keep the compatibly with Android versions lower than Honeycomb, I'm using the Support Library. But I was wondering, is Android so smart that it will change the support library methods with the right framework ones when the app is running on Honeycomb or higher? If no, is there a way to use support library methods for lower versions and the framework methods for higher versions?
The support library is nothing else than the original framework, which was made backwards compatible for older versions of Android. There are no new APIs available on older frameworks, so it always compares the current Android version the app is running on and uses depending on that, a custom implementation or the native one. An example of the support lib:
final int version = android.os.Build.VERSION.SDK_INT;
if (version >= 17) {
IMPL = new JbMr1ViewCompatImpl();
} else if (version >= 16) {
IMPL = new JBViewCompatImpl();
} else if (version >= 14) {
IMPL = new ICSViewCompatImpl();
} else if (version >= 11) {
IMPL = new HCViewCompatImpl();
} else if (version >= 9) {
IMPL = new GBViewCompatImpl();
} else {
IMPL = new BaseViewCompatImpl();
}
The support lib is customized to compensate the missing API's for each version of Android, like you can see in this screenshot:
You can find the source code of the support lib mirrored on Github: https://github.com/android/platform_frameworks_support