質問

Updated: Now after months of experience with Android, I understand that support libraries are back ports of new features from higher API levels. For example, support lib v4 implements some of the new features using API <= 4 only.

Thanks for the help.

役に立ちましたか?

解決

What does it contain exactly? APIs from newer levels that are emulated using API level 4?

Yes and no. It contains both back-ported versions of newer APIs (such as Fragment), as well as other features that are not available outside of the support library.

From the support library documentation (emphasis mine):

The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level. This design means that your applications can use the libraries' features and still be compatible with devices running Android 1.6 (API level 4) and up.

There are multiple versions of the support library, each supporting a different minimum API level:

  • v4 supports back to 1.6 (API level 4)
  • v7 supports back to 2.1 (API level 7)
  • v8 supports back to 2.2 (API level 8)

My min API level is 15. Do I need to use (or even care about) support v4?

Maybe. Check the Support Library Features documentation. Do you need any of those things? Some, such as DrawerLayout are not available outside the support library.

他のヒント

It depends, there are some things you can only get in the support library like ViewPager for example. but if you min API is 15 you really dont need to use the support library since the support library is meant to help older API's (< 11) have the same functionality as the newer API's

If you do not need certain specific features that come with the support library (like ViewPager), then you do not need to care about the support libraries if you are only targeting the mentioned versions. But if you have decided to use one, you should stick to it - for example:

android.app.FragmentManager fm = getFragmentManager(); // returns an instance of the Fragment Manager class
android.support.v4.app.FragmentManager = getSupportFragmentManager(); // returns an instance of the support library class

and so on. Also make sure your FragmentActivity belongs to the same library that you are using.

If you are using min API level 14 or under then you probably do need the Support Library. If you are doing anything above, you dont need it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top