1- is my first activity(main) 2- is my second activity 3 - is my third activity
I want to run 2 from 1 and then form 2 run 3 , and then from 3 i am taking data and r
You cannot do this when starting 2 from 1:
Intent intent = new Intent(getApplicationContext(), MessageBox.class);
intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivityForResult(intent,5);
This will throw the exception you are getting. You cannot use FLAG_ACTIVITY_FORWARD_RESULT
and startActivityForResult()
together.
If you want 1 to get the result from 3, then you need to start 2 from 1 like this:
Intent intent = new Intent(getApplicationContext(), MessageBox.class);
startActivityForResult(intent, 5);
and then start 3 from 2 like this:
Intent intent = new Intent(getApplicationContext(), ImageReceiver.class);
intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent);
finish();
This tells Android that activity 3 (ImageReceiver
) should forward its result back to the activity that called activity 2 (MessageBox
). When activity 3 sets its result and finishes, onActivityResult()
in activity 1 will be called with the result data sent from activity 3.
comment out this line in activity 1
intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
and this line in activity 2
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
You should be all set.