I have following workflow in my code. I have fragment A
which starts a new activity B
using startActivityForResult(intent, requestCode). Activity B has a fragment say fragment C
which contains a listview (its adapter has an arraylist) and an edittext below to add new values into the listview.
I intend to send data back to fragment A
. I have implemented an interface in the fragment C
which is called in onPause() method of the same fragment.
@Override
public void onPause() {
// TODO Auto-generated method stub
OnSubtaskExitListener onSubtaskExitListener = (OnSubtaskExitListener) getSherlockActivity();
onSubtaskExitListener.onExit(Subtasks);
super.onPause();
}
Subtasks is the updated arraylist on adding new item from add button in edit text.
I have implemented this interface in activity B
which contains the fragment C.
@Override
public void onExit(ArrayList<HashMap<String, String>> subtasks) {
....
intent.putExtra("ResultArray", stringArray);
setResult(RESULT_OK, intent);
finish();
Note that startActivityForResult was called in fragment A. Therefore, setResult has been used.
The problem: In the onActivityResult(int requestCode, int resultCode, Intent data)
of fragment A, Intent data is always null. I have used android.util.Log in the onExit method in activity B to see if data being sent in put extra is null e.g. Log.d("Array Result", stringArray[0].toString());
But onActivityResult() is always getting data null.
Please help me find the bug. Thanks :)