Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any reason to use the support.v4 library in Android?

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?

like image 524
Devin Rodriguez Avatar asked Mar 30 '14 04:03

Devin Rodriguez


People also ask

Should I use Android support libraries?

Originally a single binary library for apps, the Android Support Library has evolved into a suite of libraries for app development. Many of these libraries are now a strongly recommended, if not essential, part of app development.

Should I use legacy Android support libraries?

We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well. So all Android apps should now aim to use AndroidX, instead of the old support library.

What are the Android support libraries for?

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.

What is difference between v4 and v7 in Android?

v4 Support Libraries – These libraries are designed to be used with Android 2.3 (API level 9) and higher. And v7 Support Libraries – There are several libraries designed to be used with Android 2.3 (API level 9) and higher.


2 Answers

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).

like image 162
ianhanniballake Avatar answered Oct 19 '22 02:10

ianhanniballake


Advantages of use support v4 (as far as I know):

  1. You can use ViewPager (it only exists in support v4)
  2. You can use ArrayMap (added in API 19)
like image 25
kevin Avatar answered Oct 19 '22 02:10

kevin