Android.app or Android.support.v4.app? - android

I'm trying to implement cursor loaders into my android app. When I write the code for LoaderManagers, eclipse prompts me to import the correct libraries. However there are two options which appear to be the same; android.app and android.support.v4.app. Whats the difference between these two, and which one should I use?

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.

This both are different library android.app is for the i.e. Fragment which are available from the API level 3.0 and above. So to use the Fragments in below api's you have to use its backword compatible libraries form android.support.v4.app to support below the API level than 3.0. So android has provided the flexibility to provide the support in lower version using android.support.v4.app library.
Each Support Library is backward-compatible to a specific Android API level. So whenever you are implmenting anything which is available in 3.0 but not below then you should use its support library.

Related

Android App Which Targets API21, needs AppCompat?

I am going to build a new app, targeting API21 and higher, do I need AppCompat v7 or I can omit it?
It depends on what features you want to implement and which functionalities you want to develop. Targeting API level and minimum API level are both different thing. Your selection of support libraries depends upon your your minimum API level, that is defined by minSdkVersion.
You can decide and derive below conclusion from official Android Developer Documentation:
v4 Support Library
This library is designed to be used with Android 2.3 (API level 9) and higher. It includes the largest set of APIs compared to the other libraries, including support for application components, user interface features, accessibility, data handling, network connectivity, and programming utilities.
v7 Libraries
There are several libraries designed to be used with Android 2.3 (API level 9) and higher. These libraries provide specific feature sets and can be included in your application independently from each other.
v7 AppCompat library
This library adds support for the Action Bar user interface design pattern.
Note: This library depends on the v4 Support Library. If you are using Ant or Eclipse, make sure you include the v4 Support Library as part of this library's classpath.
v13 Support Library
This library is designed to be used for Android 3.2 (API level 13) and higher. It adds support for the Fragment user interface pattern with the (FragmentCompat) class and additional fragment support classes.

Is android support library part of android framework APIS?

I am new to android app development.I don't understand what the android support library is?.Is it included in android framework APIs like API level 17,18 or is it separate API which can be included in projects.Thanks in advance!!
Is it included in android framework APIs like API level 17,18
No.
or is it separate API which can be included in projects
Yes.
Quoting the documentation:
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.

Need Some clarification about "android-support-v4.jar"

I am facing some questions on android-support-v4.jar now a days.
What is android-support-v4.jar
What will happen if we remove android-support-v4.jar from \libs folder
Which class files are there in android-support-v4.jar
What is exact usage of android-support-v4.jar in Android
It is the Support Library for Android that provides backward compatibility for developers to use new API Level features in mobiles that doesn't provide that feature. Hence using Support Library you can broaden the range of targeted mobile devices.
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.
You app or atleast some of the features will not work on Android Devices with Older API levels like Honeycomb or Freyo.
You can see all the classes in android-support-v4.jar here.
Eg: Including Support Library you can use ViewPager in API Level 8 which is Freyo.
You can know everything about android-support-v4.jar here.

Android Action compatibility from 2.2 to 4.2

I am trying to create an Application on Android and want to target apps all the way down to Android 2.2.
I am a bit confused on how to configure the application
Min SDK: 2.2
Target SDK: 4.1
Compile SDK against: 4.2
This is the default config i got when i created a new Android Project.
Should i still need to use ActionBar Sherlock to support the older versions ?
Unless you are using any API's not available for lower versions, you will not require any additional libraries like ActionBarSherlock.
However, if you are using any specific API's and want to make them backward compatible, for example Fragments, ActionBar, etc then you can make use of the Support Library which supports a minimum API level of 4.
Quote from the Support Library Page:
Minimum API level supported: 4
The Support Package includes static "support libraries" that you can
add to your Android application in order to use APIs that are either
not available for older platform versions or that offer "utility" APIs
that aren't a part of the framework APIs. The goal is to simplify your
development by offering more APIs that you can bundle with your
application so you can worry less about platform versions.
ABS is an extension of the Support Library. This is from the ABS page Link: ActionBarSherlock:
The library will automatically use the native action bar when
appropriate or will automatically wrap a custom implementation around
your layouts. This allows you to easily develop an application with an
action bar for every version of Android from 2.x and up.
To summarize, if you are making use of API's not available in older SDK's, then you can use either of the two listed above. If you are not using API's specific to newer SDK's, you will not need ABS or the Support Library.
Min SDK = Least API you want to support ie., 2.2
Target SDK = API you want to test on. If not set will take default value as Min SDK. Usually target will be the Max API you want to support or the Latest API. This is to tell the Application to use the latest API Features, but if not possible allow backwards compatibility.
I never heard about Compile SDK
and you don't need any Support libraries if you are using only 2.2 API elements.
For something like Fragments etc.., which are not present in <3.0 API you must use Support Libraries.

Which are the minimum API requirements of the compatibility package?

I know the Compatibility Package is very useful and provides backward compatibility. One thing i am not sure, will all the libraries in the package can be used on all version of Android let say above 2.1.
Note: The Support Package includes more than one support library. Each one has a different minimum API level. For example, one library requires API level 4 or higher, while another requires API level 13 or higher (v13 is a superset of v4 and includes additional support classes to work with v13 APIs). The minimum version is indicated by the directory name, such as v4/ and v13/.
http://developer.android.com/tools/extras/support-library.html
To support 2.1, use compatibility library "v4".

Categories

Resources