In Kotlin I'm overriding this two Google Sign-In functions:
override fun onConnectionFailed(result: ConnectionResult) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE)
} catch (e: IntentSender.SendIntentException) {
// Unable 到 resolve, message user appropriately
}
} else {
val gaa = GoogleApiAvailability.getInstance()
gaa.getErrorDialog(this, result.errorCode, 0)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
when (requestCode) {
RESOLVE_CONNECTION_REQUEST_CODE -> if (resultCode == Activity.RESULT_OK) {
mGoogleApiClient!!.connect()
}
}
}
到 check if the connection 到 google fails.
The problem is that sometimes, when I dismiss the dialog containing user accounts, which pop-up when the activity is launched
就像这个:
I'm getting an IllegalArgumentException
with the following logcat
E/AndroidRuntime:致命异常:主
这就指向了onActivityResult
函数.
我试着改变
requestCode: Int
到
requestCode: Int?
但是很明显,我得到了一个错误,因为该函数与它的超类中的函数不同.
我该怎么修?