OnActivityResult() is deprecated in androidx. I took reference from below links
- https://developer.android.com/training/basics/intents/result
- https://developer.android.com/jetpack/androidx/releases/activity
- https://proandroiddev.com/is-onactivityresult-deprecated-in-activity-results-api-lets-deep-dive-into-it-302d5cf6edd
I implemented for signup thing in my project ..like .I created resultcontract by registering the activity
in place of startActivityForResult i replaced by resultcontract.launch(intent) and getting result in resultcontract (followed above links). Now i have doubt in one function that is turn on gps.
for this we have used
val rae = e as ResolvableApiException
rae.startResolutionForResult(context, GPS_REQUEST)
earlier it was startActivityForResult , now it is startResolutionForResult
having confusion how to get result of gps request ( in code , we are getting result in
onActivityResult).how can i implement this using new way?
I found a solution for this problem, using the recent API's to start something for result.
So, you can pretty much get the resolution from
ResolvableApiException, which is aPendingIntent, and start it withStartIntentSenderForResultcontract, like thiscontract:
how to start: