Alright, here I am again. Still learning. Now I need to pass integer values back and forth from 2 activities. First activity passes a counter value to the second (which k
Do like this
startActivityForResult(i, 100);
For setResult
setResult(RESULT_OK);
You can use setresult for more advanced sending of results something like
intent = new Intent();
intent.putExtra("key", "I am done");
setResult(1001, intent);
And in onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 100)
{
String key = data.getStringExtra("key");
if(resultcode == 1001 && key!= null && key.equals("I am done"){
//do something
}else{
//do something else
}
}
}
You dont have to use setResult, if all you need to check is whether you returned from the activity then dont set it and dont check in onActivityResult