Activity restart on rotation Android

前端 未结 30 3843
花落未央
花落未央 2020-11-21 04:32

In my Android application, when I rotate the device (slide out the keyboard) then my Activity is restarted (onCreate is called). Now, this is proba

30条回答
  •  余生分开走
    2020-11-21 05:10

     onConfigurationChanged is called when the screen rotates. 
     (onCreate is no longer called when screen rotates due to manifest, see:  
     android:configChanges)
    

    What part of the manifest tells it "don't call onCreate()"?

    Also, Google's docs say to avoid using android:configChanges (except as a last resort).... But then the alternate methods they suggest all DO use android:configChanges.

    It has been my experience that the emulator ALWAYS calls onCreate() upon rotation.
    But the 1-2 devices that I run the same code on... do not. (Not sure why there would be any difference.)

提交回复
热议问题