rarp
rarp

Reputation: 1122

Android system dialog causes app to crash

My app has this line of code

requestWindowFeature(Window.FEATURE_NO_TITLE);

before it calls this line

setContentView(R.layout.home_layout);

My problem is that when the app crashes (for whatever reason), Android shows a Crash Data dialog the next time it starts, causing it to crash with the error "requestFeature() must be called before adding content". Is there a workaround for this?

EDIT: The issue is that the system is adding content to the screen before I call requestfeature() causing my application to crash.

Upvotes: 0

Views: 539

Answers (2)

Yosi199
Yosi199

Reputation: 1804

You need to ask for this feature before you inflate the view itself. When using this way:

requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.home_layout);

You are saying something like - "Please inflate a layout named R.layout.home.layout, and inflate it with no title bar"

Upvotes: 0

Samir Mangroliya
Samir Mangroliya

Reputation: 40416

requestFeature() must be called before adding content

Dont call setContentView before requestWindowFeature

Use Like

requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.home_layout);

Upvotes: 1

Related Questions