-1

I have a question about onCreate() call and orientation changes in Android. According my readings android should always recreate activity when orientation of device is changed (if you do not declare other behavior in manifes, or some other way). That is clear. Based on this information i made my logic in application and most of the time i tested this app in android emulator with API level 10. I can see from log, that when orientation is changed then onCreate() of current activity is called. But when i try do the same in API level 19 for example, then onCreate() is not called after orientation change. My Question is why onCreate() is not call on "newer" APIs, what cause this? And second how to achieve same beaviour in API 10 and 19?

I verified this also on base "hello world" activity to eliminate possible cause like my manifest, but behaviour is the same.

serenesat
  • 4,611
  • 10
  • 37
  • 53
msmetak
  • 43
  • 6

2 Answers2

1

Unless you adding "orientation" configChanges to manifest, onCreate() must be called.

Check for that configChanges and remove if you have it.

pjanecze
  • 3,145
  • 3
  • 21
  • 28
  • With or without _android:configChanges="orientation|screeSize"_ behaviour is the same on emulators. onCreate() is called inI'm using android studion – msmetak Mar 20 '15 at 13:32
  • Sorry, ignore my first comment my mistake - ENter keyboard. I have the manifest without configChanges attribute. But i tried also changed this and put log info into onConfigurationChanged() method but this methotd was not called neether. Logcat in android studio shows me my log and log from system_process - "config changed ...") in case of API 10 but when i run API 19 there is no such information . .. i'm donwloading other emulators right now. – msmetak Mar 20 '15 at 13:39
  • Hmm, it's weird, but I am 100% sure that something is wrong on your side - either code or emulator. If it would't work on API19 all of my applications would crash ;) – pjanecze Mar 20 '15 at 14:32
  • Yes something has to be wrong with emulator on my workstation, i tried same app at home on my laptop and it workes fine. Currently i'm not abble to load even android 10 on my workstation until i uncheck "Use host GPU" which works before friday. And orientation changes stops working in that device too. – msmetak Mar 23 '15 at 10:08
1

There is the cause of my original issue: https://stackoverflow.com/a/20539347/4345570 it's a bug in android emulator API level 19.

Community
  • 1
  • 1
msmetak
  • 43
  • 6