0

As mentioned in several answers, calling requestWindowFeature(Window.FEATURE_NO_TITLE) should be before super.onCreate(...) and setContentView(...).
However, I want the screen's title to appear when the activity is created, and to disappear only after returning from another activity.
I tried this:

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CONNECT_DEVICE: 
            requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
}

And I'm getting the android.util.AndroidRuntimeException: requestFeature() must be called before adding content exception.

Community
  • 1
  • 1
Presen
  • 1,629
  • 4
  • 25
  • 44

1 Answers1

1
// try this way,hope this will help you....

Note : i think what you trying do is not possible so try this alternative.
public class FirstActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        if(!getIntent().getBooleanExtra("isTitleShow",true)){
            requestWindowFeature(Window.FEATURE_NO_TITLE);
        }
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // this condition for stop to call SecondActivity after one time call
        if(getIntent().getBooleanExtra("isTitleShow",true)){
            Intent intent = new Intent(this,SecondActivity.class);
            startActivity(intent);
            finish();
        }
    }
} 


public class SecondActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Intent intent = new Intent(this,MainActivity.class);
        intent.putExtra("isTitleShow",false);
        startActivity(intent);
    }
}
Haresh Chhelana
  • 23,930
  • 5
  • 51
  • 66