Suppose there is an ActivityGroup A, which contains two sub-activities B and C, jump to another Activity D in C, and then execute some operations in D, refresh the D interface when you finish and return D again. How can this problem be achieved?
In C, c. startActivityForResult (D, 0), and setResult (1) Before D finish (). Therefore, the onActivityResult in C cannot receive the return code 1 returned from D, the interface cannot be refreshed.
Solution:
C start D:
[Java]
Intent intent = new Intent (C. this, D. class );
GetParent (). startActivityForResult (intent, 0 );
Then rewrite onActivityResult in:
[Java]
Protected void onActivityResult (int requestCode, int resultCode, Intent data ){
// TODO Auto-generated method stub
Super. onActivityResult (requestCode, resultCode, data );
If (requestCode = 0 ){
C activity = (C) getLocalActivityManager (). getCurrentActivity ();
Activity. handleActivityResult (requestCode, resultCode, data); // send the received message to Activity C that initiates the request
}
}
Finally, add the handleActivityResult method to C.
[Java]
Public void handleActivityResult (int requestCode, int resultCode, Intent data ){
If (resultCode = 1) {// get the return code and refresh the interface
Log. I (TAG, "Return Code:" + resultCode );
}
}