Search code examples
androidandroid-actionbaronresume

Android: actionbar dissapeared after returning to the app


I've got an app with android:minSdkVersion set to "4".

When I run this app on my HTC one X (4.0.3) I have a actionbar and everything is okay, but when I turn of my phone and return to the app the actionbar disappeared.

Is there an manifest command or something to always show the actionbar when possible?

This isn't allowed in my app because of the minSdkVersion.

    ActionBar actionBar = getActionBar();
    actionBar.show();

Thank you very much for your help!


Solution

  • You can use the Android Compatibility Library for this; it will provide your app with an action bar on older versions of Android, and then you can use getSupportActionBar(). It also provides you with an Activity base class you can extend; called ActionBarActivity which takes care of this sort of logic for you.

    Alternately, you can check out ActionBar Sherlock which (to the best of my knowledge) provides a superset of the support library capability.