Extending FragmentActivity instead of Activity

I have an application code base with several actions. I have a BaseActivity class that extends the Activity class and is the parent class for all Activities in my application. BaseActivity takes care of the state that my application leaves in the background and returns to the foreground. Now I have written several operations that use fragments so that these new actions are extended by FragmentActivity . But my application requires that all actions extend the BaseActivity class.

The solution in my opinion:

  • BaseActivity extends FragmentActivity instead of the Activity class.
  • New actions (with fragments) extend BaseActivity instead of directly expanding FragmentActivity.

With this solution, I am afraid of any side effect in my existing actions that extend the Activity class (via BaseActivity ). Now these actions will be expanded by FragmentActivity (although they do not have fragments inside). This is normal if I extend FragmentActivity , even if I don't have a fragment inside. Will it behave the same as Activity?

+6
source share
1 answer

like FragmentActivity extends Activity , so it looks great .jsut you need to add the compitiblilty library if you want to provide support for older versions

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

Even I did the same and did not find a side effect.

+2
source

Source: https://habr.com/ru/post/919117/


All Articles