Anix PasBesoin Anix PasBesoin - 6 months ago 27
Android Question

App crashing when trying to hide the title bar

In order to make a full screen app,
I ve done the following changes in the manifest of a new "blank activity" project:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"


The application crashes when running on any device. This changes have been recommended by many posts here in SO and I cannot seem to find what I ve done wrong.

Here is the whole manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity
android:name="com.example.app.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Answer

just do below way

import android.support.v7.app.ActionBarActivity;

extend

    public class SplashScreen extends ActionBarActivity {

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            getSupportActionBar().hide();


            setContentView(R.layout.splash_screen);
    }
}

its working fine with API level 7 or higher

EDIT:

user AppCompatActivity because ActionBarActivity @deprecated in API 23

Comments