android - onActivityResult in First Activity not returning result after finish second activity -
activity calls activityb using following code
startactivityforresult(new intent(context, activityb), 1);
activity b calls activity c by:
startactivityforresult(new intent(context, activityc), 2);
i finish activity c return result , start new activity d there
startactivity(new intent(context, activityd); setresult(result_ok, new intent()); finish();
i want finish activity , activity b on return result
but not getting return result. in case
onactivityresult no calling in activity , activity b
in short want function
btngo.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent next = new intent(activityc.this, activityd.class); startactivity(next); setresult(result_ok, next); finish(); } });
i getting 1 thing of both. going next activity or returing result back. want going next activity return result simultaneously.
may not setting requestcode why have issue,try way
public final static int go_for_country = 11; public final static int go_for_state = 12; @override public void onclick(view v) { switch (v.getid()) { case r.id.register_country: intent intents=new intent(registration.this,countrylist.class); startactivityforresult(intents, go_for_country); break; case r.id.register_state: intent intentstate=new intent(registration.this,statelist.class); intentstate.putextra("cids",cid); startactivityforresult(intentstate, go_for_state); break; default: break; }
and in onactivityresult
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (resultcode == activity.result_ok) { switch (requestcode) { case go_for_country: try { //your stuff } catch (exception e) { e.printstacktrace(); } break; case go_for_state: try { //your stuff } catch (exception e) { e.printstacktrace(); } break; } } }
Comments
Post a Comment