3

It is possible to avoid the call to onCreate when you changue from landscape to portrait?

How?

thanks

NullPointerException
  • 32,153
  • 66
  • 194
  • 346

4 Answers4

2

Absolutely possible, in AndroidManifest.xml add this to activity:

android:configChanges="orientation|keyboardHidden"

you can read more information about this tip on my article: http://xjaphx.wordpress.com/2011/09/19/the-less-known-over-screen-orientation/

Pete Houston
  • 14,087
  • 6
  • 41
  • 57
2

Read this article Handling Runtime Changes. Basically there are two options

  1. Let android handle configuration changes - then your activity will be recreated and onCreate will be invoked again.

  2. Handle it yourself - then your activity won't be destroyed.

Mojo Risin
  • 8,072
  • 5
  • 43
  • 57
1

Yes it is possible to do this, by adding android:configChanges="orientation" to your manifest.

However, by choosing this path, you lose much of the great resource management in Android.

If you want to appropriately save and restore state since the activity is recreated without the above manifest change, then you will want to look at onSaveInstanceState () and onRestoreInstanceState ()

Community
  • 1
  • 1
Mike dg
  • 4,508
  • 2
  • 24
  • 26
0

add this to manifest of the activity - android:configChanges="orientation"

ShineDown
  • 1,833
  • 3
  • 21
  • 29