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 to 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()
}
}
}
to check if the connection to google fails.
The problem is that sometimes, when I dismiss the dialog containing user accounts, which pop-up when the activity is launched
Like this one:
I'm getting an IllegalArgumentException
with the following logcat
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.dancam.subscriptions, PID: 6346 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=6783, result=0, data=null} to activity {com.dancam.subscriptions/com.dancam.subscriptions.ActiveSubscriptions.Subscriptions_main}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter data at android.app.ActivityThread.deliverResults(ActivityThread.java:4126) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4169) at android.app.ActivityThread.-wrap20(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1552) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6186) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter data at com.dancam.subscriptions.ActiveSubscriptions.Subscriptions_main.onActivityResult(Subscriptions_main.kt:0) at android.app.Activity.dispatchActivityResult(Activity.java:6937) at android.app.ActivityThread.deliverResults(ActivityThread.java:4122) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4169) at android.app.ActivityThread.-wrap20(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1552) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6186) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
that points to the onActivityResult
function.
I tried changing
requestCode: Int
to
requestCode: Int?
But then I obviously get an error because the function is not the same as the one from it's superclass.
How can I fix it?
you need to mention data
as null
so do data: Intent?
because data
intent can be null
when action is cancelled or no result was sent
Failure delivering result ResultInfo{who=null, request=6783, result=0,
data=null
} to activity Parameter specified asnon-null is null
:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// ^^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With