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
}