I started a new app with the master detail template.
When I try the app on my tablet, using the two-pane layout, it crashes with the exception in the title when I change orientation of the tablet. This happens only if the detail fragment has content.
The crash is in super.onCreate line, I'm not even calling requestFeature, so it's not even my code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
if (findViewById(R.id.item_detail_container) != null) {
// The detail container view will be present only in the
// large-screen layouts (res/values-large and
// res/values-sw600dp). If this view is present, then the
// activity should be in two-pane mode.
mTwoPane = true;
// In two-pane mode, list items should be given the
// 'activated' state when touched.
((ItemListFragment) getSupportFragmentManager().findFragmentById(
R.id.item_list)).setActivateOnItemClick(true);
}
}
Stack trace:
12-14 23:18:44.716: E/AndroidRuntime(32065): FATAL EXCEPTION: main
12-14 23:18:44.716: E/AndroidRuntime(32065): Process: com.manor.barcam, PID: 32065
12-14 23:18:44.716: E/AndroidRuntime(32065): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.manor.barcam/com.manor.barcam.ItemListActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.ActivityThread.access$900(ActivityThread.java:135)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.os.Handler.dispatchMessage(Handler.java:102)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.os.Looper.loop(Looper.java:136)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.ActivityThread.main(ActivityThread.java:5017)
12-14 23:18:44.716: E/AndroidRuntime(32065): at java.lang.reflect.Method.invokeNative(Native Method)
12-14 23:18:44.716: E/AndroidRuntime(32065): at java.lang.reflect.Method.invoke(Method.java:515)
12-14 23:18:44.716: E/AndroidRuntime(32065): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-14 23:18:44.716: E/AndroidRuntime(32065): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-14 23:18:44.716: E/AndroidRuntime(32065): at dalvik.system.NativeStart.main(Native Method)
12-14 23:18:44.716: E/AndroidRuntime(32065): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
12-14 23:18:44.716: E/AndroidRuntime(32065): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:249)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.Activity.requestWindowFeature(Activity.java:3298)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:63)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
12-14 23:18:44.716: E/AndroidRuntime(32065): at com.manor.barcam.ItemListActivity.onCreate(ItemListActivity.java:54)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.Activity.performCreate(Activity.java:5231)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-14 23:18:44.716: E/AndroidRuntime(32065): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
12-14 23:18:44.716: E/AndroidRuntime(32065): ... 12 more
How can I solve it?
Thanks.