Search code examples
pixate

PixateFreestyle Android - App Crash


I have successfully imported the pixate freestyle for Android and able to design my buttons.

I am experiencing a app crash problem once I use the following code

PixateFreestyle.init(this);

It works for the first time, and If I access any activity after using the above code it throws the following runtime exception :

Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:249)

If i remove the code PixateFreestyle.init(this); app is working fine and normal.

Kindly guide me If I am missing anything


Solution

  • I was having the same issue and found that moving my call to requestWindowFeature() before the call to super.onCreate() fixed it. Check for any calls that contain requestFeature in the activity that is crashing, and make the calls before super.onCreate().

    Example:

    change this:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_ACTION_BAR);
    }
    

    to this:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_ACTION_BAR);
        super.onCreate(savedInstanceState);
    }