Android - Activity vs FragmentActivity?

zaz picture zaz · Mar 10, 2013 · Viewed 109.3k times · Source

I am new in Android. I want to build an app with tab format. I found many documentation where Activity has been used. Also in many cases have used FragmentActivity. I am not sure which will be better to start. Please suggest me should I use Activity or FragmentActivity to start development in tab format?

Answer

ray picture ray · Mar 10, 2013

ianhanniballake is right. You can get all the functionality of Activity from FragmentActivity. In fact, FragmentActivity has more functionality.

Using FragmentActivity you can easily build tab and swap format. For each tab you can use different Fragment (Fragments are reusable). So for any FragmentActivity you can reuse the same Fragment.

Still you can use Activity for single pages like list down something and edit element of the list in next page.

Also remember to use Activity if you are using android.app.Fragment; use FragmentActivity if you are using android.support.v4.app.Fragment. Never attach a android.support.v4.app.Fragment to an android.app.Activity, as this will cause an exception to be thrown.