• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

What's the difference between "Array<Uri>?" and "Array<Uri?>"?

Daniel Fernandes

Android Enthusiast
I get this type mismatch error that I don't really understand, I've been stuck on it for quite a long while and I haven't really figured it out. The error looks like this:

Type inference failed. Expected type mismatch:
required: Array<Uri>?
found: Array<Uri?>

What exactly does the question mark mean and what's the difference in their positions?

I get this error at onActivityResult. The activity has a webview. When the user clicks an "Upload Image" button on the website, the app shows a file chooser, and gets the result back, then the image is sent to webview. Here's its code snippet:

Code:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if(resultCode == file_req_code){
            if (resultCode == Activity.RESULT_CANCELED) {
                file_path?.onReceiveValue(null) //file_path is the filePathCallback
                return
            }

            if(resultCode == Activity.RESULT_OK){
                if (file_path == null){
                    return
                }
                var image: Array<Uri>? = null
                image = arrayOf(data.data) //I get the error here! "arrayOf(data.data)" is underlined in red. 
                file_path?.onReceiveValue(image)
            }
        }
    }
 
Back
Top Bottom