Issue
I am at activity A, and launching some other activities such as B and C with the launcher like this
private val resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK) {
// any way to get activity name that set the result?
}
}
// Launch activity B by a button click
resultLauncher.launch(Intent(this, B::class.java))
// Launch activity C by a button click
resultLauncher.launch(Intent(this, C::class.java))
When finishing both B and C, I use this code
setResult(RESULT_OK) // don't want to put Intent data to this method
finish()
So Does the ActivityResult param in registerForActivityResult contain any info of the activities (such as simpleClassName) that call setResult and go back to activity A? I don't want to put the intent data to setResult method
Solution
So Does the ActivityResult param in registerForActivityResult contain any info of the activities (such as simpleClassName) that call setResult and go back to activity A?
No. The documentation for ActivityResult
shows that it contains the result code Int
and the Intent
that get delivered to onActivityResult()
.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.