6

I try to prevent that onCreate() is called when rotating the device. To reach this goal I followed the documentation and added

<activity android:name=".TabActivity"
          android:label="@string/app_name"
          android:configChanges="orientation">
     <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
</activity>

to the manifest. After that I inserted this to the Activity's source code:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}

But it seems like Android ignores this method. A breakpoint which I set here is never reached.

What's my fault here? Is this a problem when using tabs?

Regards!

J H
  • 63
  • 2
  • Your code looks OK. Did you try to set a breakpoint in your `onCreate()` to determine whether it is executed again (it should not as you said) when you switch your device's orientation? – Shlublu Aug 30 '11 at 08:08
  • 1
    Just see the post right below. Felix gave a good explanation. – J H Aug 30 '11 at 08:17

1 Answers1

5

Try this:

  android:configChanges="orientation|keyboardHidden"
Bart Blommaerts
  • 821
  • 5
  • 15
  • 1
    +1 that's the correct solution. If it doesn't work, try adding `keyboard` as well. – Felix Aug 30 '11 at 08:12
  • 3
    @J H because the emulator (and some devices) has a physical (emulated) keyboard. Thus, when you rotate it, it actually sends both `keyboardHidden` and `orientation` configuration changes, because it basically emulates popping the physical keyboard out. – Felix Aug 30 '11 at 08:13