Activity is getting destroyed while pressing the home button

前端 未结 6 811
感动是毒
感动是毒 2020-12-19 03:50

In my application, when I press the home button the activity is going to onDestroy(). It suppose to be called onPause() method only right?

6条回答
  •  悲哀的现实
    2020-12-19 04:07

    Well, it depends on a lot of factors. If you are facing this issue on Android 3.2+ devices, you should add screenSize property to android:configChanges

        android:configChanges="keyboardHidden|orientation|screenSize"
    

    Besides, also add android:launchMode="singleTop" to your launcher activity. Do note that you'd need to use Android SDK 15 or above as target, however, your app will work on older devices as well. Hope this helps.

提交回复
热议问题