i use three activity ActiviytA, ActivityB and ActivityC.from ActivityA have onActivtResult function i need result from Activityc in b/w i travel through the activityB
问题:
回答1:
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);
回答2:
Thats very easy. You also can implement an onActivityResult inside ActivityB and then just pass it back to activity A:
if(RESULT_OK)
{
//GET data passedback
Intent returnIntent = new Intent();
returnIntent.putExtra(your extra data);
setResult(RESULT_OK, returnIntent);
finish()
}
this is the way I always use my home button implementations.