In my MainActivity, I hava code looks like this:
public void toSecondActivity(View v){
if(condition1){
Intent it = new Intent(MainActitivy.this,SecondAcitivity.class);
......
startActivityForResult(it,1)
}
else if(condition2){
Intent it = new Intent(MainActitivy.this,SecondAcitivity.class);
......
startActivityForResult(it,2)
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == 3) {
}
else if (resultCode == 4){
}
}
Then in SecondActivity I have this code:
public void returnToMainAcitivity(View v){
Intent it = getIntent();
.........
it.putExtra("ResourceID", mResourceId);
setResult(3, it);
finish();
}
My question is: how to set the result to 4 if it is started from condition2 using the same button?
public void returnToMainAcitivity(View v){
Intent it = getIntent();
.........
setResult(4, it);
finish();
}
I am new to intentions, so please teach me how to solve this problem. Thanks;)
source
share