Difference Between Android.App.Fragment and Android.Support.V4.App.Fragment

Difference between android.app.Fragment and android.support.v4.app.Fragment

android.support.v4.app.Fragment is the Fragment class in the android support library, which is a compatibility package that allows you to use some of the newer features of Android on older versions of Android.

android.app.Fragment is the Fragment class in the native version of the Android SDK. It was introduced in Android 3 (API 11).

If you want to make your app use fragments, and want to target devices before API 11, you must use android.support.v4.app.Fragment. However, if you're only targeting devices running API 11 or above, you can use android.app.Fragment.

Edit: the OS-contained android.app.Fragment is now deprecated (as of API level 28), and everyone should move to using the support library implementations.

Difference between support-v4.app.fragment and app.fragment?

If you're developing for Android 3+, you can use app.Fragment.

However, in 3-, Fragments didn't exist yet. That is where the support library comes in. It provides Fragments for older versions of Android.

See also this link

android.support.v4.app.FragmentManager OR android.app.FragmentManager?

First of all: your activity should extend FragmentActivity.

About support libraries. They were introduced to add some functionalities to older Androids. For example Fragments were introduced in Android 3.0 (SDK nr: 11). In fact (according to documentation) in Androids 3.0 < support libary uses system implementation of Fragments.

Confused by android.support.v4.app.FragmentActivity and android.app.FragmentTransaction

All the apps I write need to support right back to Android 2.3 and this is the easiest way to do it.
If you're supporting 11+ then stick to android.app.Fragment.

android.support.v4.app.Fragment is the Fragment class in the android support library, which is a compatibility package that allows you to use some of the newer features of Android on older versions of Android.
android.support.v4.app.Fragment is a library that you can use to get backwards-compatibility for older API version.

android.app.Fragment is the Fragment class in the native version of the Android SDK. It was introduced in API 11.
If you want to make your app use fragments, and want to target devices before API 11, you must use android.support.v4.app.Fragment. If you're only targeting devices running API 11 or above, you can use android.app.Fragment.

Android.app Fragments vs. android.support.v4.app using ViewPager?

You can use ViewPager with native fragments from the android.app package with the adapters from the android.support.v13.app package. You have to use the v13 support jar for that.

There are two versions of the adapters that work with ViewPager, the ones in the v4 package are meant to be used with support fragments, the ones in v13 with native fragments.

The reason why there are now two fragment implementations is historical: Fragments in the android.app package were introduced with Android 3 for tablets only and the support library was created to bring fragments to phones running older versions. On Android 4 you have both.

From my own experience I would recommend using support fragments, even when developing for Android 4. Here are some reasons: Fragment or Support Fragment?



Related Topics



Leave a reply



Submit