js091514
js091514

Reputation: 165

Android full screen activity error

I am trying to create a full screen activity:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

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

        setContentView(R.layout.activity_main);
   }

I get the following error:

requestFeature() must be called before adding content

Upvotes: 3

Views: 392

Answers (1)

Pedro Lobito
Pedro Lobito

Reputation: 98861

Put the requestWindowFeature before super.onCreate

public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
   }

Upvotes: 3

Related Questions