Is It Possible To Share An Image On Android Via A Data Url?
Solution 1:
Is it possible to share an image with code something like this?
No, because ACTION_SEND
does not use the Uri
. It uses EXTRA_TEXT
or EXTRA_STREAM
.
My goal is to make my app not require permissions to write to storage, but to be able to share images that it dynamically creates. Is there any way to do this?
Create a ContentProvider
to serve the file, then put the Uri
pointing to your file within your provider in EXTRA_STREAM
. You may be able to protect the provider with a custom permission and allow the sending activity temporary access to it via FLAG_GRANT_READ_URI_PERMISSION
, though I have only tried that with Intent
structures that use the actual Uri
(e.g., setData()
) instead of via an extra like EXTRA_STREAM
.
This sample project demonstrates this technique using ACTION_VIEW
(note: requires a device with a PDF viewer installed to truly work).
Post a Comment for "Is It Possible To Share An Image On Android Via A Data Url?"