startActivityForResult usage for multiple activities

After naming activity in startActivityForResult(ActivityB,0) we give request code for the specified activity ie; startActivityForResult(ActivityB,REQUEST_CODE_FOR_ACTIVITYB). with request code being any integer. Then in onActivityResult check for each request code and implement your logic


SOLUTION:

Activity A -> startActivityForResult(activityB,0);
Activity B -> activityCintent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); startActivity(activityCintent); finish();
Activity C -> activityDintent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); startActivity(activityDintent); finish();
Activity D -> setresult(10); finish();
Activity A -> if(result==10) {dofunction(); } YEPPP

this is the logic of FLAG_ACTIVITY_FORWARD_RESULT. First you start an activity for result, new activity sends this intent to another new activity until you set result. I hope this will be helpful for people having same problem.

Tags:

Android