kotlinurlshareimplicit

How to share url from android app with image preview


I want to create a share sheet just like the share exist in google store , as you can see here is google store sample

currently I am using this code :

    ShareCompat.IntentBuilder(context)
        .setType("text/plain")
        .setText("TITLE\nhttp://www.url.com")
        .startChooser()

but I am not able to set an image in the share sheet, the result of my implementation: my implementation result


Solution

  • the issue was just on adding the title inside set text :

     ShareCompat.IntentBuilder(context)
        .setType("text/plain")
        .setText("TITLE\nhttp://www.url.com")
        .startChooser()
    

    so the solution is to remove it to be , so the OS will be able to read the url content from it :

     ShareCompat.IntentBuilder(context)
        .setType("text/plain")
        .setText("http://www.url.com")
        .startChooser()