I have a DialogActivity which is called from a Fragment for show a custom Dialog with two image buttons.
In DialogActivity.onCreate
final Dialog dialog = new Dialog(this, R.style.DialogTheme);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_pause);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.show();
In DialogActivity.onClick
@Override
public void onClick(View v) {
Log.d(LOGTAG, "onClick CONTINUE");
Intent resultData = new Intent();
resultData.putExtra("TEST", "return data");
setResult(666, resultData);
dialog.cancel();
}
In Fragment that calls startActivityForResult:
Intent dialogActivityIntent = new Intent(getActivity(), DialogActivity.class);
startActivityForResult(dialogActivityIntent, 999);
In Activity and Fragment that calls startActivityForResult:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
When I click the button I only get the dialog cancel and shows the background activity (fragment).
There isn't any call to onActivityResult, onResume, ... in the Fragment or the Activity contains the Fragment.
Things I tried:
To implement onActivityResult in both, Fragment and Activity that contains my Fragment.
Things to know:
I set the attribute noHistory=true in every Activity I have.
If I do finish() in onClick the Activity/Fragment that calls DialogActivity is closed too, and the application return to the before Activity.
This may be the problem, I DON'T call finish() ... but if I call finish(), it exits to another Activity, not the Activity that calls startActivityForResult.
Links I checked:
Cannot get to trigger onActivityResult() android?
startActivityForResult doesn't seem to call onActivityResult
Android onActivityResult NEVER called
onActivityResult() not called when Activity started from Fragment
I hope everything is clearly explained ^^.
Thanks in advance.