1

I have installed latest Android Studio (version 1.2 build on 29 April 2015) and created a new project from it.

I can see it generates code that uses deprecated classes like ActionBarActivity and etc. These classes were deprecated several years ago.

Is there a way to configure it to generate decent code that is not deprecated?

jorel
  • 808
  • 7
  • 15
  • 1
    Several years? What a joke. `ActionBarActivity` was deprecated in support library 22.1.1 aka the latest version, and you just have to replace it with `AppCompatActivity` which codewise does the exact same thing. – EpicPandaForce May 11 '15 at 06:15
  • 1
    @EpicPandaForce, what about addPreferencesFromResource? You had to jump the gun just like that? – jorel May 11 '15 at 06:53
  • 1
    that's because `PreferenceFragment` doesn't exist under API Level 11, although you **can** hack it in using something like this https://gist.github.com/cbeyls/7475726 . `addPreferencesFromResource` works perfectly fine on all Android versions despite being deprecated. – EpicPandaForce May 11 '15 at 07:11

1 Answers1

0

Use this app theme Theme.AppCompat.Light.DarkActionBar always. it will generate new code.

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Umer
  • 1,566
  • 2
  • 20
  • 31