• Register
0 votes
393 views

Problem :

Currently I am facing below error very regularly

“ Android.util.AndroidRuntimeException: requestFeature() must be called before adding content” error.

If you can carefully see in my below code, my requestWindowFeature(Window.FEATURE_NO_TITLE); line is comming before the line setContentView(R.layout.mainmenu);.I never had any errors in my android code before until few days from now. Recently I had updated to ADT 22 and since then many random errors are popping up from everywhere. I have fixed many of those errors and this is by far the most difficult one.

Is there anybody who has fix on above error?

Below is my code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.mainmenu);

 

8 4 2
2,300 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I saw your question. I also faced this problem in the past but when I tried to call the window request just before calling the super.onCreate() and magically my problem was solved, You can also try it with the help of below code.

@Override
public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainmenu);
}

You can also hide your Status Bar on your Android 4.0 and Lower as below

<application

    ...

    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >

    ...

</application>

You can use the activity theme for below reasons :

· It makes it very easy to maintain and also makes less error-prone than setting the flag programmatically.

· It makes the smoother UI transitions.

Hope this solution will help you.

5 2 1
4,980 points

Related questions

0 votes
1 answer 20 views
20 views
Problem: the ad size and ad unit id must be set before loadad is called.
asked Feb 21 charles mathews 5.5k points
0 votes
1 answer 2 views
2 views
Problem: Do you have any suggestions about how i can solve this problem,"imageloader must be init with configuration before using."
asked 1 day ago sumaiya simi 8.4k points
0 votes
1 answer 10 views
10 views
Problem : Your content must have a listview whose id attribute is 'android.r.id.list'
asked Feb 25 Shovo210 13.2k points
0 votes
1 answer 3 views
3 views
Problem Someone tell me about the method which is called before the oncreateview method in fragment's lifecycle.
asked 3 days ago salim1 32.1k points
0 votes
1 answer 11 views
11 views
Problem: please solve it... int java.util.arraylist.size()' on a null object reference android
asked Apr 1 Ifra 24.4k points
0 votes
1 answer 70 views
70 views
Problem: failed to convert value of type java.util.hashmap to string.
asked Feb 18 Ethan ross 2.3k points
0 votes
1 answer 2 views
2 views
Problem: I used Google to endeavor to find a solution on the web of the above question, But I got no utilizable hints. Can I get Pointer information about my quandary with this?
asked Mar 30 rakib1 51.3k points
0 votes
1 answer 3 views
3 views
Problem: Can any one help me out? I am new in python(tag name). Its show this : the activity must be exported or contain an intent-filter.
asked Mar 31 nabin shrestha 2.6k points
0 votes
1 answer 55 views
55 views
Problem: Why I got the error : the activity must be exported or contain an intent-filter. Can some one please help fix this, Help I am new in this language. Any Ideas on what I need to fix this? Thanks in advance.
asked Feb 28 James Smith 8.9k points
1 vote
1 answer 21 views
21 views
Problem: the activity must be exported or contain an intent-filter.
asked Feb 23 Ethan ross 2.3k points