1

I am trying to return an image from the camera app into a webview, however the onActivityResult is depreciated and I am having trouble updating this with my beginner Kotlin and android dev experience.

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

    if (requestCode != REQUEST_SELECT_FILE || imagePathCallback == null) return

    var results: Array<Uri>? = null

    if (resultCode == RESULT_OK) {
        if (data == null) {
            if (cameraImagePath != null) results = arrayOf(Uri.parse(cameraImagePath))
        } else {
            val dataString = data.dataString
            if (dataString != null) results = arrayOf(Uri.parse(dataString))
        }
    }

    imagePathCallback?.onReceiveValue(results)
    imagePathCallback = null
}

Any help would be hugely appreciated.

Xilitom
  • 13
  • 3
  • 1
    There is a hot discussion about this question. https://stackoverflow.com/questions/62671106/onactivityresult-method-is-deprecated-what-is-the-alternative – ocos Aug 04 '22 at 14:36

0 Answers0