manisha
10/20/2018 - 4:17 PM

Intents

resultCode=1;
setResult(resultCode);
finish();
public final static int REQ_CODE = 1;
 
Intent i = new Intent(MainActivity.this, SecondActivity.class);
startActivityForResult(i, REQ_CODE);
 
//After coming back for SecondActivity this code will execute
 
//Below code should be outside onCreate
 
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQ_CODE) {
        if (resultCode == 1) {
            
            //......
        }
    }
    //result from other activities can also be handled here using other IF statements 
    //as they will have different REQ_CODES
}