Better to use FragmentActivity (or ActionBarActivity) or system Activity when targeting min API 14 (ICS)?

Randy Sugianto 'Yuku' picture Randy Sugianto 'Yuku' · Feb 2, 2014 · Viewed 7.6k times · Source

I'm making my app to have minimum Android version of 4.0 (ICS, API level 14).

First I guessed that I can get rid of using FragmentActivity as the base class for the activities, but it seems that some support library classes like FragmentStatePagerAdapter is not available on the system framework, and it needs the support Fragment instead of the system Fragment.

So I wonder if I should make my activities inherit from the system Activity, or stay using FragmentActivity (or ActionBarActivity when using appcompat library)?

Answer

CommonsWare picture CommonsWare · Feb 2, 2014

some support library classes like FragmentStatePagerAdapter is not available on the system framework, and it needs the support Fragment instead of the system Fragment.

That is incorrect. There are two versions of FragmentPagerAdapter and FragmentStatePagerAdapter. One set (v4) uses the backport, the other (v13) uses the native API Level 11 version of fragments.

I wonder if I should make my activities inherit from the system Activity

Yes, unless you need nested fragments. Those did not show up until API Level 17. If you need that capability, you will need to use the backport, until such time as your android:minSdkVersion is 17 or higher.