8

So I'm using a gps class to turn on the gps and here's a method that allow us to send to onActivityResult, but since is deprecated on AndroidX and still available, android team recommend us the next:

it is strongly recommended to use the Activity Result APIs introduced in AndroidX

I have a the following code where I try to send to onActivityResult

val rae = e as ResolvableApiException
rae.startResolutionForResult(context,Constants.GPS_REQUEST)

How do I approach the same thing with the new API?

Barrufet
  • 352
  • 4
  • 18

2 Answers2

10

What I did in Kotlin was:

registerForActivityResult(StartIntentSenderForResult()) { result ->
    if (result.resultCode == RESULT_OK) {
        // Your logic
    }
}.launch(IntentSenderRequest.Builder(rae.resolution).build())

Original answer: https://stackoverflow.com/a/65943223/4625681

Dhananjay Suresh
  • 750
  • 1
  • 9
  • 25
0

Here is described that is not deprecated

Phantom Lord
  • 554
  • 3
  • 11
  • 2
    ResolvableApiException is not deprecated, onActivityResult is: [here says that is better to use a different approach developer](https://developer.android.com/training/basics/intents/result) – Barrufet Dec 15 '20 at 09:16