我希望将分数值从一个活动传递给另一个活动。我在新活动中添加了意图和getExtras,但似乎没有获得该值。在Android中的活动之间传递数据?
活动1;
Intent intent = new Intent(Game.this, EndGame.class);
intent.putExtra("put_score", score);
startActivity(intent);
Game.this.finish();
活动2;
Bundle extras = getIntent().getExtras();
if (extras != null) {
score = extras.getString("put_score");
}
setContentView(R.layout.endgame);
scoreResult = (TextView) findViewById(R.id.scoreNum);
scoreResult.setText(score);
有什么问题? – MatheusJardimB
您在'scoreResult'处看到什么值? – nikis
活动1中得分值为19,活动2得分值为零。它似乎没有提供或得到分数值。 – Seatter