The ActionBar is null. That's because you're using an activity without a title (and thus also without an actionbar):
requestWindowFeature(Window.FEATURE_NO_TITLE);
There are two ways to fix it.
Simple:
Make YourActivity
NOT extends ActionBarActivity
but normal Activity
.
More difficult:
Make transparent ActionBar
with no title, no icon, no home button etc. How to do this? First, define ActionBar style and new theme that extends YourAppTheme
:
<!-- Your App Theme-->
<style name="YourAppTheme.Light" parent="@style/Theme.AppCompat.Light">
<...>
</style>
<!-- Transparent ActionBar Style -->
<style name="YourAppTheme.Light.ActionBar.Transparent" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">@android:color/transparent</item>
<item name="background">@android:color/transparent</item>
</style>
<!-- Fullscreen Activity Theme -->
<style name="YourAppTheme.FullScreen.Light" parent="@style/YourAppTheme.Light">
<item name="android:actionBarStyle">@style/YourAppTheme.Light.ActionBar.Transparent</item>
<item name="actionBarStyle">@style/YourAppTheme.Light.ActionBar.Transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="windowActionBarOverlay">true</item>
</style>
Next, set this theme to your fullscreen activity:
<activity
android:name="your.package.name.YourFullscreenActivity"
android:label="@string/app_name"
android:theme="@style/YourAppTheme.FullScreen.Light" />
Finally, add following lines to YourFullscreenActivity#onCreate
method:
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
I hope it will help.