这是我当前的活动代码
Intent i = new Intent();
i.putExtra("BonusScore", score);
setResult(Activity.RESULT_OK, i);
现在我想在之前的活动中BonusScore
。
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
// TODO Extract the data returned from the child Activity.
BonusScore = Bonus.getIntExtra("BonusScore", 0);
Log.d("splash_bonus", BonusScore+"");
}
}
我试过这段代码但没有用 请帮助我,提前谢谢
答案 0 :(得分:0)
替换行:
BonusScore = Bonus.getIntExtra("BonusScore", 0);
with:
BonusScore = data.getIntExtra("BonusScore", 0);
应该这样做。
答案 1 :(得分:0)
在这里你必须这样做。
int bonus = data.getIntExtra("BonusScore", 0);
您必须在onActivityResult