onActivityResult 已弃用 我该如何发送 startResolutionForResult
onActivityResult is deprecated how do I send startResolutionForResult
所以我正在使用 gps class 打开 gps,这是一个允许我们发送到 onActivityResult
的方法,但由于在 AndroidX 和 上已弃用仍然可用,android 团队推荐我们下一个:
it is strongly recommended to use the Activity Result APIs introduced in AndroidX
我有以下代码,我尝试将其发送到 onActivityResult
val rae = e as ResolvableApiException
rae.startResolutionForResult(context,Constants.GPS_REQUEST)
如何使用新的 API 处理相同的事情?
Here
被描述为未被弃用
我在 Kotlin 中所做的是:
registerForActivityResult(StartIntentSenderForResult()) { result ->
if (result.resultCode == RESULT_OK) {
// Your logic
}
}.launch(IntentSenderRequest.Builder(rae.resolution).build())
原回答:
所以我正在使用 gps class 打开 gps,这是一个允许我们发送到 onActivityResult
的方法,但由于在 AndroidX 和 上已弃用仍然可用,android 团队推荐我们下一个:
it is strongly recommended to use the Activity Result APIs introduced in AndroidX
我有以下代码,我尝试将其发送到 onActivityResult
val rae = e as ResolvableApiException
rae.startResolutionForResult(context,Constants.GPS_REQUEST)
如何使用新的 API 处理相同的事情?
Here 被描述为未被弃用
我在 Kotlin 中所做的是:
registerForActivityResult(StartIntentSenderForResult()) { result ->
if (result.resultCode == RESULT_OK) {
// Your logic
}
}.launch(IntentSenderRequest.Builder(rae.resolution).build())
原回答: