I want to create a quiz app. On ProfileActivity is the list name using recycler view. And on NewProfileActivity, user need to enter their name, and the name will be displayed on the ProfileActivity.
This is the code button in the NewProfileActivity:
final Button save_profile_button = findViewById(R.id.button_save);
save_profile_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent save_profile_intent = new Intent();
if (TextUtils.isEmpty(mProfileNameView.getText())) {
setResult(RESULT_CANCELED, save_profile_intent);
} else {
String profile_name = mProfileNameView.getText().toString();
save_profile_intent.putExtra(EXTRA_REPLY, profile_name);
setResult(RESULT_OK, save_profile_intent);
}
finish();
}
});
It will go back to the ProfileActivity, and able to display the name user entered. But when I change the flow, from NewProfileActivity to QuestionActivity, the name does not appear on ProfileActivity. This the code that doesn't work:
final Button save_profile_button = findViewById(R.id.button_save);
save_profile_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent save_profile_intent = new Intent();
if (TextUtils.isEmpty(mProfileNameView.getText())) {
setResult(RESULT_CANCELED, save_profile_intent);
} else {
String profile_name = mProfileNameView.getText().toString();
save_profile_intent.putExtra(EXTRA_REPLY, profile_name);
setResult(RESULT_OK, save_profile_intent);
}
Intent goto_question_intent = new Intent(NewProfileActivity.this, QuestionActivity.class);
startActivity(goto_question_intent);
}
});
How can I change the flow and still able to display the name? Using this flow: MainActivity -> ProfileActivity -> NewProfileActivity -> QuestionActivity -> ResultActivity -> MainActivity -> ProfileActivity