I've been working on an app that is targeting Android 4.0 and above with no plans of supporting earlier versions. Is there any good reasons for me to continue using the support library?
问题:
回答1:
There are a number of features unique to the support library that apply to all API levels:
- LocalBroadcastManager - Allows applications to easily register for and receive intents within a single application without broadcasting them globally.
- ViewPager - Adds a ViewGroup that manages the layout for the child views, which the user can swipe between.
- DrawerLayout - Adds support for creating a Navigation Drawer that can be pulled in from the edge of a window.
- SlidingPaneLayout - Adds widget for creating linked summary and detail views that appropriately adapt to various screen sizes.
- FileProvider - Adds support for sharing of private files between applications.
And others such as
- WakefulBroadcastReceiver - Helper for the common pattern of implementing a BroadcastReceiver that receives a device wakeup event and then passes the work off to a Service, while ensuring that the device does not go back to sleep during the transition.
- AtomicFile - for atomic operations on a file
- SwipeRefreshLayout - adds pull to refresh to a view
Also note that some newer features, such as nested Fragments (which were added only in Android 4.2) are available in the support library versions of Fragments. Renderscript intrinics were also only introduced in Android 4.2 and important if you are doing things such as real time image processing. Big style notifications and notification actions (introduced in Android 4.1) are much easier to work with when using NotificationCompat (and the Android Wear Notification API is built on it).
回答2:
Advantages of use support v4 (as far as I know):
- You can use ViewPager (it only exists in support v4)
- You can use ArrayMap (added in API 19)
回答3:
You can use android-support-v13 if your minSdkVersion is >=13. The jar is in $ANDROID_HOME/extras/android/support/v13