Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending FragmentActivity instead of Activity

I have my application code base with multiple activities in it. I have a BaseActivity class which extends Activity class and is the parent class for all Activities in my application. BaseActivity takes care of the state my application goes in background and comes back to foreground. Now I have written few more Activities which are using fragments so these new Activities are extending FragmentActivity. But my application design requires that all activities should extend BaseActivity class.

Solution in my mind:

  • BaseActivity extend FragmentActivity instead of Activity class.
  • New activities(with fragments) extend BaseActivity instead of directly extending FragmentActivity.

With this solution I am afraid of any side effect in my existing activities which were extending Activity class (through BaseActivity). Now these activities will extend FragmentActivity (although they are not having fragments inside). Is it okay if I extend FragmentActivity even though I dont have any fragment inside. Will it behave same as Activity?

like image 719
deepak4bin Avatar asked Jun 27 '12 10:06

deepak4bin


1 Answers

as FragmentActivity extends Activity so looks it's fine.jsut you need to add compitiblilty library if want to give the support for old versions

http://developer.android.com/reference/android/support/v4/app/FragmentActivity.html

Even I did same and found no side effect yet

like image 119
Dheeresh Singh Avatar answered Oct 27 '22 04:10

Dheeresh Singh