I'm trying to pass the users integer score from the second activity back to the first using an intent. When I press the back button in the second activity, the score on the first activity just says "Score". I can't figure out why it's not displaying/updating the integer score. Any help would be much appreciated.
First Activity:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if(resultCode == RESULT_OK){
Integer score = data.getIntExtra(SCORE, 0);
mScore.setText(score.toString());
}
if (resultCode == RESULT_CANCELED) {
}
}
}//onActivityResult
Second Activity:
@Override
public void onPause(){
super.onPause();
Intent returnIntent = new Intent();
returnIntent.putExtra(TileActivity.SCORE, mScore);
if(getParent() == null) {
setResult(RESULT_OK, returnIntent);
}else{
getParent().setResult(RESULT_OK, returnIntent);
}
//finish();
}
Aucun commentaire:
Enregistrer un commentaire