android - Passing data though multiple activities -
1- first activity(main) 2- second activity 3 - third activity
i want run 2 1 , form 2 run 3 , , 3 taking data , returning 1. hope guys understand.
here code:
runing 2 form 1 liek :
intent intent = new intent(getapplicationcontext(),messagebox.class); intent.setflags(intent.flag_activity_forward_result); startactivityforresult(intent,5);
and running 3 2 this:
intent intent = new intent(getapplicationcontext(),imagereceiver.class); startactivityforresult(intent,5);
and in 3 have this:
setresult(10); finish();
so set result in 2 result have:
if(requestcode==5) { if(resultcode==10) { intent intent = new intent(getapplicationcontext(),mainactivity.class); setresult(5,intent); finish(); } }
and in 1 got:
if(requestcode==5) { if(resultcode==5) { //here taking data 3 } }
problem cant open 2 coz in logcat getting:
04-23 22:13:15.579: e/androidruntime(15313): android.util.androidruntimeexception: forward_result_flag used while requesting result
and dont should do. please @ code.
you cannot when starting 2 1:
intent intent = new intent(getapplicationcontext(), messagebox.class); intent.setflags(intent.flag_activity_forward_result); startactivityforresult(intent,5);
this throw exception getting. cannot use flag_activity_forward_result
, startactivityforresult()
together.
if want 1 result 3, need start 2 1 this:
intent intent = new intent(getapplicationcontext(), messagebox.class); startactivityforresult(intent, 5);
and start 3 2 this:
intent intent = new intent(getapplicationcontext(), imagereceiver.class); intent.setflags(intent.flag_activity_forward_result); startactivity(intent); finish();
this tells android activity 3 (imagereceiver
) should forward result activity called activity 2 (messagebox
). when activity 3 sets result , finishes, onactivityresult()
in activity 1 called result data sent activity 3.
Comments
Post a Comment