【发布时间】:2022-07-02 22:12:51
【问题描述】:
我有点卡在我正在编写的函数中。
我有一个函数调用我编写的另一个应用程序并需要返回一个布尔值
@Composable
fun callApp(
//someparams
) : Boolean {
//some code
}
经过一些逻辑,我通过以下方式启动我的应用程序:
val startForResult =
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
if (result.resultCode == Activity.RESULT_OK) {
//here i need to set the return value of "callApp"
}}
并通过
触发它startForResult.launch(launchIntent)
问题是我看不到一种方法可以返回函数“callApp”在结果中生成的布尔值。 请注意,我不能使用 sharedPref/realm/代码本身外部的任何数据结构。
你能帮我理解一下吗?
【问题讨论】:
标签: kotlin android-jetpack-compose activityresultcontracts