In Activity A, I click a button to go to Activity B. I bring data using Bundle
back to the Activity A and I managed to change a String value
in the ListView
. Then I go to another Activity C to manipulate another data. The problem is, when I get back again to the Activity A, the data from the Activity C is reflected in the ListView
, but the previous data from the Activity B is gone.
Here's a code to the Activity B from the Activity A.
private void gotoRepeatWeeklyOptionActivity() {
Intent intent = new Intent(CreateNewAlarmActivity.this, RepeatWeeklyOptionActivity.class);
startActivity(intent);
finish();
}
This one is the method from the Activity A to the Activity C.
private void openAlarmToneOptionDialog() {
Intent intent = new Intent(CreateNewAlarmActivity.this, ChooseAlarmToneActivity.class);
startActivity(intent);
}
And this is a code that leads to the Activity A from the Activity B.
@Override
public void onBackPressed() {
Intent intent = new Intent(this, CreateNewAlarmActivity.class);
ArrayList<Integer> repeatStatusIntList = new ArrayList<>();
intent.putExtra(Keys.OPTION, Keys.OPTION_REPEAT);
if(cbRepeatEveryDay.isChecked()) {
super.onBackPressed();
intent.putExtra(Keys.VALUE, Keys.EVERY_DAY);
Toast.makeText(this, getString(R.string.alarm_will_repeat_every_day), Toast.LENGTH_SHORT).show();
} else if(allUnchecked()) {
super.onBackPressed();
intent.putExtra(Keys.VALUE, Keys.NO_REPEAT);
Toast.makeText(this, getString(R.string.alarm_will_never_repeat), Toast.LENGTH_SHORT).show();
} else {
for(int i=0; i<repeatStatusList.size(); i++) {
super.onBackPressed();
if(repeatStatusList.get(i).isChecked()) {
repeatStatusIntList.add(getRepeatStatusInt(repeatStatusList.get(i)));
intent.putIntegerArrayListExtra(Keys.KEY_REPEAT_STATUS_INTEGERS_LIST, repeatStatusIntList);
}
intent.putExtra(Keys.VALUE, Keys.ON);
}
Toast.makeText(this, getString(R.string.alarm_will_repeat) + getString(R.string.every) +
getAllRepeatDays(repeatStatusList), Toast.LENGTH_SHORT).show();
}
startActivityForResult(intent, RESULT_OK);
finish();
}
Finally, this is a code from the Activity C, which leads back to the Activity A.
btnSelectTone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), CreateNewAlarmActivity.class);
intent.putExtra(Keys.OPTION, Keys.OPTION_ALARM_TONE);
intent.putExtra(Keys.VALUE, ringtone);
if(mediaPlayer.isPlaying()) {
mediaPlayer.stop();
mediaPlayer.release();
}
startActivityForResult(intent, RESULT_OK);
finish();
}
});