Should I replace ActionBarActivity with AppCompatActivity?

I’m following the Android lesson, and in the Support section of Android 2.1 and above it says that my Activity should extend the ActionBarActivity class to support the API-7 action bar and beyond.

However, the documentation also says that this class is deprecated, and I should use AppCompatActivity instead. I'm confused here, which one should I use and why?

+5
source share
2 answers

Yes. You must use AppCompatActivity .

AppCompatActivity is a very new class, and the training section on the android website is deprecated.

Everything you do with ActionBarActivity will work mainly on AppCompatActivity .

For differences, please read the post about this http://android-developers.blogspot.de/2015/04/android-support-library-221.html

+13
source

I understand that you need to use AppCompatActivity. If other support libraries or classes are now deprecated, this means that people on Android will not continue to support this code or improve it. However, I have never used any of these classes.

I suggest that you might have some ugly if statements to check the API level of your end users and make different method calls based on this. That sounds like a lot of extra work though.

0
source

All Articles