[Solved] How send result to back to previous activity in android? [closed]


If I understood well, you open ActivityB from ActivityA, and then ActivityC from ActivityB. You want ActivityA to get values from ActivityC.

Probably the easiest way is to store the values as static, and read them directly from the class.

If you want to use StartActivityForResult (so you can get the results from onActivityResult), you should make ActivityB receive the results from C, and then make ActivityB pass the results to ActivityA:

ActivityA implements ResultsReciever. Then start Activity B, and retrieve the calling activity (ActivityA) with

interface ResultsReciever{
    executeSomething(ArrayList values);
}

Declare ActivityA implementing the interface:

public class ActivityA extends Activity implements ResultsReciever

On Activity B, at the onStart method:

ResultsReciever caller = (ResultsReciever)getCallingActivity();

Then ActivityB starts ActivityC with StartActivityForResult(). In the onActivityResult in ActivityB you can call then:

caller.executeSomething(whatever);

solved How send result to back to previous activity in android? [closed]