I've got three activities A, B and C. From activity A I can call activity B and from B I can call C, and I can call activity C from activity A directly as well.
The thing is that when returning the result from C directly to A through setResult
and onbackpressed
methods everything works fine. The problem comes when from activity C I return the result to B, and in its onActivityResult
I call once again setResult
and onbackpressed
to pass that same result to activity A.
Activity
A comes up again but in this case its onActivityResult
is never triggered.
Here is some code.
In activity C:
if (selection) {
setResult(RESULT_OK, data);
} else {
setResult(RESULT_CANCELED, data);
}
selection = false;
super.onBackPressed();
In activity B get C's result and try to pass it back to activity A
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode) {
case RESULT_OK:
setResult(RESULT_OK, data);
onBackPressed();
break;
case RESULT_CANCELED:
if (list_search != null && !list_search.getAdapter().isEmpty()) {
list_search.setSelection(data.getIntExtra("position", 0));
}
break;
}
}
And here A onActivityResult
. I get the result either if it comes from B or from C, But its only triggering when coming directly from C. when is coming through B, A appears, but is not triggering onActivityResult
so I can't retrieve the data in this case.
public void OnActivityResult(int requestCode, int resultCode, Intent intent) {
....
switch (resultCode) {
case RESULT_CANCELED:
sincronizaCursorArticulos(intent.getStringExtra("cd_articulo"));
break;
case RESULT_OK:
sincronizaCursorArticulos(intent.getStringExtra("cd_articulo"));
fragment_order_entering.setEtArticulo(intent.getStringExtra("cd_articulo"));
fragment_order_entering.loadArticulo(false);
break;
}
}
Thanks so much in advance.