1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

Discussion in 'Android Development' started by Daniel Fernandes, Jan 16, 2020.

  1. Daniel Fernandes

    Daniel Fernandes Android Enthusiast
    Thread Starter

    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 (Text):
    1. override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    2.         super.onActivityResult(requestCode, resultCode, data)
    3.         if(resultCode == file_req_code){
    4.             if (resultCode == Activity.RESULT_CANCELED) {
    5.                 file_path?.onReceiveValue(null) //file_path is the filePathCallback
    6.                 return
    7.             }
    8.  
    9.             if(resultCode == Activity.RESULT_OK){
    10.                 if (file_path == null){
    11.                     return
    12.                 }
    13.                 var image: Array<Uri>? = null
    14.                 image = arrayOf(data.data) //I get the error here! "arrayOf(data.data)" is underlined in red.
    15.                 file_path?.onReceiveValue(image)
    16.             }
    17.         }
    18.     }
     

    Advertisement

    racibennett likes this.
Loading...
Similar Threads - What's difference between
  1. Rob
    Replies:
    3
    Views:
    262
  2. MoodyBlues
    Replies:
    10
    Views:
    214
  3. Android News
    Replies:
    0
    Views:
    100
  4. Android News
    Replies:
    0
    Views:
    53
  5. Kurniawan
    Replies:
    4
    Views:
    2,113
  6. James_Watson
    Replies:
    0
    Views:
    1,326
  7. James_Watson
    Replies:
    1
    Views:
    501
  8. a cooperator
    Replies:
    2
    Views:
    536
  9. Big Boar
    Replies:
    8
    Views:
    913

Share This Page

Loading...