0

Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

here is my code,

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_SWIPE_TO_DISMISS);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main);
}}
bubu uwu
  • 463
  • 2
  • 12
  • 26

1 Answers1

5

requestFeature() must be called before adding content

Well, just do what the error message tells you.

Don't call setContentView() before requestFeature().

Note:

As said in comments, for both ActionBarSherlock and AppCompat library, it's necessary to call requestFeature() before super.onCreate()

Community
  • 1
  • 1
bubu uwu
  • 463
  • 2
  • 12
  • 26