简体   繁体   中英

FragmentActivity class for below api level 11 devices

I am new to android development.

I created class and extend that class from FragmentActivity .

When I use this function getFragmentManager()

it does not allow me to do it

I am also unable to use getSupportFragmentManager because its also giving me error that can not convert from support api to android.app

But then I used TargetApi(11) attribute on my abstract class that I extend from FragmentActivity class.

Now the error is gone.

But I like to know, does targetApi(11) limits my app from running my app on adroid devices below api 11?

Or below api 11 does not allow fragmment or hence does not support FragmentActivity class ?

If last thing that i mention is true, should I instead of fragment should I use new activities?

TargetApi(11) only suppress lint warning, you app can still run below 11. however if may crash if API is not available in lower Android platform.

The correct way to solve your issue is use Android support library, it include FragmentActivity in package android.support.v4.app .

You need edit you gradle file to include android support library

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:support-v4:22.2.0'
}

Then sync gradle file and recompile your project.

Don't import android.app.FragmentActivity. It need api larger than android 3.0. You can import android.support.v4.app,FragmentActivity!! And you problem is solved!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM