模拟仿真器杀伤活性仿真器、活性

2023-09-12 04:15:12 作者:喪鐘

我想测试一下的onSaveInstanceState onRestoreInstanceState 我在模拟器应用程序。

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

我已经找到this,它说,我们可能在方向变化模拟这一点,但我存储我的一些变量在应用层(子类 android.app.Application ),所以方向变化不消灭变量。

I have found this, which says that we could simulate this during orientation change, but I'm storing some of my variables on the application level (subclass android.app.Application), so the orientation change does not wipe out the variables.

所以我的问题是,我怎么可以模拟这样的内存不足情况下杀害了我的活动?

So my question is, how can I simulate the low memory situation thus killing of my activities?

希望我自己清楚。谢谢

推荐答案

您可以暂停您的应用程序(通过按下Home键,模拟电话,等等)。然后杀应用程序的通过亚行的过程。由于文档说,经过的onPause()返回您的应用程序可以在没有任何进一步的通知被杀害,这是一个公平的测试。

You can pause your application (by pushing the Home button, simulating a call, whatever). Then kill the app's process through adb. Since the docs say that after onPause() returns your app can be killed without any further notice, this is a fair test.