The SDK should therefore be updated to use the Activity Result API, as should the documentation + sample code, which currently recommend the client uses the deprecated method onActivityResult.
For the SDK to implement the Activity Result API, it could be as simple as a new static function in AuthorizationClient such as the following:
fun createLoginActivityResultContract(contextActivity: Activity) = object : ActivityResultContract<AuthorizationRequest, AuthorizationResponse>() {
override fun createIntent(context: Context, input: AuthorizationRequest): Intent =
AuthorizationClient.createLoginActivityIntent(contextActivity, input)
override fun parseResult(resultCode: Int, intent: Intent?): AuthorizationResponse =
AuthorizationClient.getResponse(resultCode, intent)
}
(or the Java equivalent).
Then, instead of instructing the client to call the following from their Activity:
(or the Java equivalent -- although the documentation & sample code should be updated to use Kotlin as it has been Google's preferred language for Android developers to use since 2019).
Something like this would bring the SDK up to date, remove developer confusion at the recommendation to use deprecated methods, and remove the need to use arbitrary result codes. Thanks!
The current implementation of
AuthorizationClient
calls startActivityForResult and expects the user to call onActivityResult, both of which are now deprecated in favor of the Activity Result API.The SDK should therefore be updated to use the Activity Result API, as should the documentation + sample code, which currently recommend the client uses the deprecated method
onActivityResult
.For the SDK to implement the Activity Result API, it could be as simple as a new static function in AuthorizationClient such as the following:
(or the Java equivalent).
Then, instead of instructing the client to call the following from their
Activity
:they should call:
where
requestSpotifyAuth
is a property of theActivity
declared as:(or the Java equivalent -- although the documentation & sample code should be updated to use Kotlin as it has been Google's preferred language for Android developers to use since 2019).
Something like this would bring the SDK up to date, remove developer confusion at the recommendation to use deprecated methods, and remove the need to use arbitrary result codes. Thanks!