Simulate killing of activity in emulator

前端 未结 7 1978
误落风尘
误落风尘 2020-12-01 06:26

I would like to test out onSaveInstanceState and onRestoreInstanceState for my app on the emulator.

I have found this, which says that we c

7条回答
  •  有刺的猬
    2020-12-01 07:12

    The simplest solution which works for me is just change the orientation of the device (you can do that regardless you're using AVD, Genymotion or any other emulator). By default system will recreate Activity by calling onDestory followed by onCreate.

    Ensure Activity has not defined below attribute on AndroidManifest.xml

    android:configChanges="orientation"
    

提交回复
热议问题