How to simulate killing activity to conserve memory?

后端 未结 8 1761
清酒与你
清酒与你 2020-12-15 15:22

Android doc say:

\"When the system, rather than the user, shuts down an activity to conserve memory, ... \"

But how to simulate

8条回答
  •  旧时难觅i
    2020-12-15 16:15

    Use the SetAlwaysFinish app (works on a real device and in the emulator) or use the Google DevTools app (works in the emulator only).

    These apps use the hidden AlwaysFinish setting of the ActivityManagerNative class to change the behavior of the OS and cause it to immediate unload every activity as soon as it's no longer in the foreground. This will reliably trigger the onSaveInstanceState and onRestoreInstanceState events.

    See link below for more details: http://bricolsoftconsulting.com/how-to-test-onsaveinstancestate-and-onrestoreinstancestate-on-a-real-device/

提交回复
热议问题