📜  不推荐使用结果的启动活动 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:44.155000             🧑  作者: Mango

代码示例1
var resultLauncher = registerForActivityResult(StartActivityForResult()) { result ->
    if (result.resultCode == Activity.RESULT_OK) {
        // There are no request codes
        val data: Intent? = result.data
        doSomeOperations()
    }
}

fun openSomeActivityForResult() {
    val intent = Intent(this, SomeActivity::class.java)
    resultLauncher.launch(intent)
}