Android 版本兼容 向下兼容
1.6、2.1还是占有一定的市场,故在有些时候,我们还是得要考虑兼容这些版本。
google提供了Android Support Library package 系列的包来保证来高版本sdk开发的向下兼容性,即我们用4.x开发时,在1.6等版本上,可以使用高版本的有些特性,如fragement,ViewPager等,下面,简单说明下这几个版本间的区别:
Android Support v4 ( 1.6 ):
这个包是为了照顾1.6及更高版本而设计的,这个包是使用最广泛的,eclipse新建工程时,都默认带有了。
Android Support v7 ( 2.1 ):
这个包是为了考虑照顾2.1及以上版本而设计的,但不包含更低,故如果不考虑1.6,我们可以采用再加上这个包,另外注意,v7是要依赖v4这个包的,即,两个得同时被包含。
Android Support v13 (3.2) :
这个包的设计是为了android 3.2及更高版本的,一般我们都不常用,平板开发中能用到。
向下兼容(Downward Compatible)
又称向后兼容(Backwards compatibility),计算机术语。向下兼容常常是相对于向上兼容而言的,两者在兼容的方向性上是相反的,因此这两个概念是不同的。
suppport jar 位于 sdk/extras/android/support
Support Libraries for Android.
This SDK component contains static libraries providing access to newer APIs
on older platforms and various helper classes.
To use those libraries, simply copy them as static libraries into your project.
Each library is called v<api>, indicating the minimum API level that they require.
*** V4 ***
v4/android-support-v4.jar contains:
- Fragment API. New in API 11 (3.0 - Honeycomb). http://developer.android.com/reference/android/app/Fragment.html
- Loader API. New in API 11 (3.0 - Honeycomb). http://developer.android.com/reference/android/app/LoaderManager.html
- CursorAdapter / ResourceCursorAdapter / SimpleCursorAdapter. These are the API 11 versions.
- MenuCompat allows calling MenuItem.setShowAsAction which only exists on API 11.
v4/src/ is the source code for the compatibility library
v4/samples/ provides a sample app using the library.
*** V13 ***
v13/android-support-v13.jar provides the same features as v4, plus:
- FragmentPagerAdapter: Implementation of PagerAdapter that represents each page as a Fragment.
v13/src/ is the source code for the compatibility library, not including the v4 source
v13/samples/ provides a sample app using the library.