0

I have a link that leads to a pdf file. I need to use Android Sharesheet to open this file with existing applications for pdf files on my phone.

I have this code, but when this dialog opens, it does not show what I need:

val share = Intent.createChooser(Intent().apply {
    action = Intent.ACTION_SEND
    putExtra(Intent.EXTRA_TEXT, "https://testsite.com/english.pdf")
    flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}, null)
context.startActivity(share)

enter image description here

onesector
  • 361
  • 5
  • 18
  • 1
    "I need to use Android Sharesheet to open this file" -- what *exactly* does "open this file" mean? `ACTION_SEND` is for sharing, and in this case you forgot the MIME type of `text/plain` to indicate that you are sharing a snippet of text (in this case, a URL). `ACTION_VIEW` is for viewing the content. – CommonsWare Oct 18 '22 at 11:16

0 Answers0