如何测试为保存/恢复活动的生命周期而构建的代码? [英] How to test code built to save/restore Lifecycle of an Activity?
本文介绍了如何测试为保存/恢复活动的生命周期而构建的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何测试以下所有方法代码?我想在所有场景都发生时播放场景,以查看我的代码是否适用于活动的保存/恢复过程.那么我应该在模拟器中做什么来测试所有方法?
How can I test all of the following methods code? I want to play scenarios when all of them are happening to see if my code works for save/restore process of an activity. So what should I do in the Emulator to get all methods tested?
public class Activity extends ApplicationContext {
protected void onCreate(Bundle savedInstanceState);
protected void onStart();
protected void onRestoreInstanceState(Bundle savedInstanceState);
protected void onSaveInstanceState(Bundle savedInstanceState);
protected void onRestart();
protected void onResume();
protected void onPause();
protected void onStop();
protected void onDestroy();
}
推荐答案
如果您在设备上启用了开发者选项,则有一个不保留活动选项将有助于测试 onRestoreInstanceState()
.
If you have enabled Developer Options on your device, there is an option Do not keep activities that will help test onRestoreInstanceState()
.
这篇关于如何测试为保存/恢复活动的生命周期而构建的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文