The parameter specified as non-null is null for the data in onActivityResult

I have the same problem as described here: https://github.com/paypal/PayPal-Android-SDK/issues/437

But I cannot solve this with the obvious solution, which is to change the signature to

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {}

because then it says that the function does not override anything (in the original method, the data is not null)

But without this, the data is sent as null, which is unacceptable. I get the following RuntimeException:

Failed to execute ResultInfo result {who = null, request = 2, result = 0, data = null} into action {... MainActivity}: java.lang.IllegalArgumentException: parameter set as nonzero is null: kotlin.jvm method .internal.Intrinsics.checkParameterIsNotNull parameter data

How can I get the data so that it is not null or are allowed to zero? I press the back button in my own activity, so I can send everything I need. I tried to add an intent with some data, i.e.

override fun onBackPressed() {
    super.onBackPressed()
    val i = Intent()
    i.putExtra("nonNull", "nonNull")
    setResult(RESULT_CANCELED, i)
    finish()
}
+4
source share

Source: https://habr.com/ru/post/1687732/


All Articles