Below code is from Google's official document about Leaderboards of Play Games Services (converted into Kotlin):
private fun showLeaderboard() {
PlayGames.getLeaderboardsClient(this).allLeaderboardsIntent
.addOnSuccessListener { intent ->
startActivityForResult(intent, 0)
}
}
Android Studio says:
'startActivityForResult(Intent!, Int): Unit' is deprecated. Deprecated in Java
How can I fix this?
You can use
ActivityResultContractsinstead of deprecatedstartActivityForResult.The Leaderboards document says:
So, in this situation (as for Leaderboards), you have nothing to do with the result in your
ActivityResultContracts.