What’s the enhancement of AppCompatActivity over ActionBarActivity?

As Chris wrote, new deprecated version of ActionBarActivity (the one extending AppCompatActivity class) is a safe to use backward compatibility class. Its deprecation is just a hint for you asking to use new AppCompatActivity directly instead. AppCompatActivity is a new, more generic implementation which uses AppCompatDelegate class internally.

If you start a new development, then you should rather use new AppCompatActivity class right away. If you have a chance to update your app, then replace deprecated ActionBarActivity by the new activity as well. Otherwise you can stay with deprecated activity and there will be no difference in behavior at all.

Regarding AppCompatDelegate, it allows you to have new tinted widgets in an activity, which is neither AppCompatActivity nor ActionBarActivity.

For instance, you inherit an activity from an external library, which, in turn, does not inherit from AppCompatActivity but you want this activity to have tinted materials widgets (views). To make it happen you need to create an instance of AppCompatDelegate inside your activity, override methods of that activity like addContentView(), setContentView() etc. (see AppCompatDelegate javadoc for the full list of methods), and inside of those overridden methods forward the calls to the inner AppCompatDelegate instance. AppCompatDelegate will do the rest and your “old-fashion” activity will be “materialized”.

Leave a Comment