Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested set activity for result android

I have 3 activities. A,B and C. A calls B, B calls C, and the result of C should be received in A. Can you please suggest how to go about it?? I m killing B using finish() after it calls C. So, the result of C should go directly to A Activityonresult. Is it possible??. Please give your suggestions!

like image 431
bharath Avatar asked Apr 16 '13 01:04

bharath


2 Answers

Don't kill B, in A start activity B using startActivityForResult and in B start activity C using startActivityForResult then in B onActivityResult

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
    super.onActivityResult(requestCode, resultCode, intent);

    setResult(RESULT_OK, intent);
    finish();
}  

where intent is the intent sent back from C. Now A will receive this intent in A onActivityResult.

like image 189
Hoan Nguyen Avatar answered Oct 07 '22 04:10

Hoan Nguyen


What if you call C from A? Something like: A calls B; instead of calling C from B, finish it and make A call C.

Unless the result of C affects B. In such case you have no choice but handling the result of C in B, and set the result of A from there if needed.

like image 29
Cristian Avatar answered Oct 07 '22 06:10

Cristian