Two ways to hide an Android ActionBar on an Activity

If you want to hide the Android ActionBar on an Activity, it looks like there are at least two approaches.

First, add the android:theme="@android:style/Theme.NoTitleBar" entry to the activity’s definition in AndroidManifest.xml:

<activity
    android:name=".PlayAGameActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.NoTitleBar" >
</activity>

A second approach is to add this code in the Activity (or Fragment) onCreate method:

getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();

I just tried both approaches in an Android app I’m working on, and I can verify that they both work.