0

我很困惑为什么会这样。当我在手机上关闭并打开我的应用程序而不终止该进程时,它会重新打开,就好像它一开始就从未打开过一样。如果我在断开电缆后继续使用通过 USB 调试发送的应用程序,它可以正常工作。如果我从 bin 文件夹中获取 APK 并安装它,它将中断。

这是我在 onSaveInstanceState 方法中保存变量的代码:

super.onSaveInstanceState(outState);
outState.putParcelableArrayList(PAIRS, pairs);
outState.putStringArrayList(PLAYERS, players);
outState.putParcelableArray(TEAMS_IN, teamsIn);
outState.putSerializable(GAMES_OUT, gamesOut);
outState.putStringArrayList(CURRENTLY_PLAYING, currentlyPlaying);       

这是在 onCreate 如果 savedInstanceState != null 时运行的代码:

pairs = savedInstanceState.getParcelableArrayList(PAIRS); //TODO: look into type
players = savedInstanceState.getStringArrayList(PLAYERS);
teamsIn = (Team[]) savedInstanceState.getParcelableArray(TEAMS_IN);
gamesOut = (HashMap<String, Integer>) savedInstanceState.getSerializable(GAMES_OUT); 
currentlyPlaying = (ArrayList<String>) savedInstanceState.getStringArrayList(CURRENTLY_PLAYING);

这可能是什么原因造成的?

4

0 回答 0