oday
07/27/2022, 1:44 PMstartActivityForResult
?
I have an Activity A that I start a Fragment A-2 inside, and that fragment A-2 starts another activity B, I need activity B to send back the result all the way to activity A using this new registerActivityForResult wayoday
07/27/2022, 1:46 PMprivate val getSelectedDateRange: ActivityResultLauncher<Intent> = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) {
if (it.resultCode == Activity.RESULT_OK) {
val value =
it.data?.getParcelableExtra<DateRange>(DateRangePickerActivity.ARG_DATE_RANGE)
Log.d("DATE_RANGE", "Date range is ${value?.startDate} and ${value?.endDate}")
}
}
and I call this getSelectedDateRange.launch
from inside the Fragment A-2 so it can start activity B, then in activity B I setResult when I’m done producing the result, then close the activity and the A-2 fragment behind it, activity A does not receive this result in the above receiver