应用状态仅在插入USB但不在仿真器上时保持一致

时间:2014-03-03 16:02:18

标签: android android-activity usb-debugging

我很困惑为什么会这样。当我在手机上关闭并打开我的应用程序而不会终止该过程时,它会重新打开,就好像它从未打开过一样。如果我继续使用断开电缆后通过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);       

如果savedInstanceState!= null:

,这是在onCreate中运行的代码
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);

可能导致这种情况的原因是什么?

0 个答案:

没有答案