我正在做一个井字游戏。
每当有结果时,我会对另一项活动有意图并传递一些数据---关于获胜者。
然后我通过getIntent()获取其他活动中的数据。但是,一旦我点击重置按钮返回播放屏幕,该数据似乎不会更新
这是我的演奏活动
if (themeChosen == 0) {
if (gameState[position[0]] == 0) {
//Noughts Won!
Log.i("winner", "normal1");
resultTextView.setText("Winner: Nought");
Intent intent = new Intent(getBaseContext(), LocalGameResultActivity.class);
intent.putExtra("winner", "normal1");
startActivity(intent);
resetGame(); //Reset Game after Result
} else {
//Cross Won!
Log.i("winner", "normal2");
resultTextView.setText("Winner: Cross");
Intent intent = new Intent(getBaseContext(), LocalGameResultActivity.class);
intent.putExtra("winner", "normal2");
startActivity(intent);
resetGame(); //Reset Game after Result
}
}
这是我的接收活动代码
String winnerString = getIntent().getStringExtra("winner"); //Getting Winner
//Handling Winner Situations
//Normal
if(winnerString.equals("normal1")){
dummyTextView.setText("Noughts Won!");
} else if(winnerString.equals("normal2")){
dummyTextView.setText("Crosses Won!");
}
非常感谢任何帮助!