Return Data From Activities |

This is a companion discussion topic for the original entry at

startActivityForResult is deprecated, please provide alternated method.

I came here to say the same. bump.

See if the following is useful. I did this in order to pass stuff from one activity to another. In MainActivity, just above onCreate, use the following code.
private val resultContract = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){
result: ActivityResult →
if (result?.resultCode == RESULT_OK){
val list =
} else if(result?.resultCode == RESULT_CANCELED){


Then the showTaskListItems function is updated as follows:

private fun showTaskListItems(list: TaskList){
val taskListIntent = Intent(this,
taskListIntent.putExtra(INTENT_LIST_KEY, list)

I believe the rest of the code is the same. Hope it works out.

This course is in the process of being updated. It should be released soon.

1 Like