This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7503473-your-second-kotlin-android-app/lessons/29
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7503473-your-second-kotlin-android-app/lessons/29
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 = result.data?.getParcelableExtra(INTENT_LIST_KEY)
listDataManager.saveList(list!!)
updateLists()
} else if(result?.resultCode == RESULT_CANCELED){
}
}
Then the showTaskListItems function is updated as follows:
private fun showTaskListItems(list: TaskList){
val taskListIntent = Intent(this, DetailActivity::class.java)
taskListIntent.putExtra(INTENT_LIST_KEY, list)
resultContract.launch(taskListIntent)
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.