Android 2.1 via eclipse
I have an activity that opens a dialog themed activity via checkbox onChecked function
Im creating this new dialog themed activity with an Intent.
Problem is, how do i dismiss the dialog themed activity once i finish with it? (the way it stands now, i have to send a new intent in order to go back to the previous activity via click of a button)
Any help would be greatly apprieciated!
Code snippet:
Main activity:
cbReminder.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked)
{
Intent intent = new Intent(getApplicationContext(), DateTimeDialog.class);
startActivity(intent);
}
}
});
Dialog themed activity:
public void onClick(View v) {
if (v.getId() == R.id.b_datetime_save)
{
}
else if (v.getId() == R.id.b_datetime_cancel)
{
finish();
Intent intent = new Intent(getApplicationContext(), MakeNoteActivity.class);
startActivity(intent);
}
}
As you specified, the intent was indeed not needed to return to the previous activity and should be removed.
To uncheck the checkbox after returning from the dialog, you can use
startActivityForResultand set a callback for when you return.Open your dialog like this:
Then add a callback to that same activity:
The
UNIQUE_IDENTIFIERcan be any number that uniquely identifies this dialog. Let me know if you have any more questions.