Bar*_*fet 5 gps android deprecated onactivityresult androidx
所以我使用 gps 类来打开 gps,这是一种允许我们发送到的方法onActivityResult,但由于在 AndroidX 上已弃用并且仍然可用,android 团队向我们推荐下一个:
强烈推荐使用AndroidX中引入的Activity Result APIs
我有以下代码,我尝试发送到 onActivityResult
val rae = e as ResolvableApiException
rae.startResolutionForResult(context,Constants.GPS_REQUEST)
Run Code Online (Sandbox Code Playgroud)
如何使用新 API 处理相同的事情?
我在 Kotlin 中所做的是:
registerForActivityResult(StartIntentSenderForResult()) { result ->
if (result.resultCode == RESULT_OK) {
// Your logic
}
}.launch(IntentSenderRequest.Builder(rae.resolution).build())
Run Code Online (Sandbox Code Playgroud)
原答案:https : //stackoverflow.com/a/65943223/4625681
| 归档时间: |
|
| 查看次数: |
757 次 |
| 最近记录: |