Is there any reason to use the support.v4 library in Android?
Solution 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).
Solution 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)