I've created a Dialog as an activity, where the user checks one of three radio buttons and the result is returned to the main activity. I followed the answer on this SO question
I thought that by creating this the MainAcitvity would pause and wait for a result from the child activity.
private void getFinalFinish() {
Intent intent_openDialog = new Intent(this, DaAAmountToFinish.class);
// Start the SecondActivity
Bundle bundle_PassToDialog = new Bundle();
bundle_PassToDialog.putInt("EXTRA_SCORE_TO_SUBTRACT", scoreToSubtractFrom);
bundle_PassToDialog.putString("EXTRA_RADIO_BUTTON", rb_selected.getText().toString());
bundle_PassToDialog.putString("EXTRA_THROWING", whosThrowing);
intent_openDialog.putExtras(bundle_PassToDialog);
startActivityForResult(intent_openDialog, DIALOG_REQUEST_CODE);
}
This code is executed when wanted, I can see this as it is displayed whenever I hit the back button (My main activity continues to the point where it opens another activity that I only want to open after I get the result from activity as a dialog).
On activity result code...
// This method is called when the dialog activity finishes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Check that it is the SecondActivity with an OK result
if (requestCode == DIALOG_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
// Get String data from Intent
int darts_to_minus = extras.getInt("DARTS_TO_MINUS");
boolean addTooScore = extras.getBoolean("ADD_TO_SCORE");
int dartsToSubtractFromFinish = extras.getInt("DARTS_TO_SUBTRACT_FROM_FINISH");
setMatchAVG(darts_to_minus, whosThrowing, addTooScore);
if (newBestLeg) {
if (whosThrowing.equalsIgnoreCase("Player 1")) {
tv_bestLeg.setText(getString(R.string.tv_BestLeg, String.valueOf(tempNumOfDartsThrownP1 + dartsToSubtractFromFinish))); //Subtract 2 off best leg only took 1 dart to finish
} else {
tv_bestLegP2.setText(getString(R.string.tv_BestLeg, String.valueOf(tempNumOfDartsThrownP2 + dartsToSubtractFromFinish)));
}
}
}
}
}
Why is this?