Repository: expo/expo
File: packages/expo-sharing/android/src/main/java/expo/modules/sharing/dataParsers/ResolvingShareIntentDataParser.kt (Kotlin)

Code before:
        e.printStackTrace()
      }

      return ResolvedSharePayload().apply {
        value = uri.toString()
        shareType = type
        this.mimeType = specificMimeType
        contentUri = file.toURI().toString()
        contentType = ContentType.fromMimeType(specificMimeType)
        contentSize = fileSize
        contentMimeType = specificMimeType
        originalName = fileName
      }
    }

    private fun getFileName(resolver: ContentResolver, uri: Uri): String? {
      var name: String? = null
      val cursor = resolver.query(uri, null, null, null, null)
      cursor?.use {
        if (it.moveToFirst()) {
          val nameIndex = it.getColumnIndex(OpenableColumns.DISPLAY_NAME)
          if (nameIndex != -1) {
            name = it.getString(nameIndex)
          }
        }
      }

      return name ?: uri.lastPathSegment
    }

    private fun getFileSize(resolver: ContentResolver, uri: Uri): Long? {
      val cursor = resolver.query(uri, null, null, null, null)
      cursor?.use {
        if (it.moveToFirst()) {
          val sizeIndex = it.getColumnIndex(OpenableColumns.SIZE)
          if (sizeIndex != -1) {
            return it.getLong(sizeIndex)
          }
        }
      }
      return null
    }

    private fun resolveUrlContext(urlString: String): ResolvedSharePayload {
      val payload = ResolvedSharePayload().apply {
        value = urlString
        shareType = ShareType.Url
        mimeType = "text/plain"
      }

      try {

Review comment (suggestion):
```suggestion
      val cursor = resolver.query(uri, null, null, null, null)
      val name = cursor?.use { cursor ->
      	val nameIndex = cursor
      	  .takeIf { it.moveToFirst() }
      	  ?.getColumnIndex(OpenableColumns.DISPLAY_NAME)
    	  
    	  if (nameIndex != -1) {
    	  	cursor.getString(nameIndex)
    	  } else {
    	    null
  	    }
      }
```

Code after:
        e.printStackTrace()
      }

      return ResolvedSharePayload().apply {
        value = uri.toString()
        shareType = type
        this.mimeType = specificMimeType
        contentUri = file.toURI().toString()
        contentType = ContentType.fromMimeType(specificMimeType)
        contentSize = fileSize
        contentMimeType = specificMimeType
        originalName = fileName
      }
    }

    private fun getFileName(resolver: ContentResolver, uri: Uri): String? {
      val cursor = resolver.query(uri, null, null, null, null)
      val name = cursor?.use { cursor ->
        val nameIndex = cursor
          .takeIf { it.moveToFirst() }
          ?.getColumnIndex(OpenableColumns.DISPLAY_NAME)

        if (nameIndex != null && nameIndex != -1) {
          cursor.getString(nameIndex)
        } else {
          null
        }
      }

      return name ?: uri.lastPathSegment
    }

    private fun getFileSize(resolver: ContentResolver, uri: Uri): Long? {
      val cursor = resolver.query(uri, null, null, null, null)
        ?: return null

      return cursor.use { cursor ->
        val sizeIndex = cursor
          .takeIf { it.moveToFirst() }
          ?.getColumnIndex(OpenableColumns.SIZE)

        if (sizeIndex != null && sizeIndex != -1) {
          cursor.getLong(sizeIndex)
        } else {
          null
        }
      }
    }

    private fun resolveUrlContext(urlString: String): ResolvedSharePayload {
      val payload = ResolvedSharePayload().apply {