Question

I am implementing fragments with a DrawerLayout. I have 2 options when I import Fragments

  1. android.support.v4.app

  2. android.app

Which one should I use ? I dont see any difference except it seems like the android.support.v4.app has no support for objectAnimator.

What do you suggest ?

Edit: I only plan on supporting API level 14 and higher...

Was it helpful?

Solution

It depends on whether you are using Support Library.

If you are using fragments below api level 11 then use android.support.v4.app. In this case you will extend FragmentActivity which is the base class of support based fragments.

If you are using fragments in api level 11 and above use android.app. In this case you will extend standard Activity.

Take a look at the below link and decide on what versions your app should run. Depending on that decide whether you need support library or not.

https://developer.android.com/about/dashboards/index.html

I only plan on supporting API level 14 and higher...

Then there is no need to use support library. Use

import android.app.Fragment

and extend standard Activity.

OTHER TIPS

If you are using support libary for drawerlayout then you should use android.support.v4.app for fragments.

You can use open-source "AndroidX" Support Library nowadays.

You can start from here AndroidX

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top