Java – can images be shared on Android via data URLs?

Can I share images with such code?

Intent share = new Intent(Intent.ACTION_SEND);
share.setData(Uri.parse("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACx"
    + "jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGoSURBVDhPlVM9SEJRGD2DkL+QmoiKYNggToJL"
    + "4KKLNDiKW4NCoENQkzS1uboILoKjW61NSZOjo1uOBlHPgjJsuN3jvc+naVQHPt79vu+cc9/37n34"
    + "BQkd/0jibw+3Ozt4j0TwwuCaNfYU5Qe43Tg5OMDD9TWEYUAIoYJr1mIxPEmjc01fh8uF03wer6vC"
    + "7zGbQZRKmPp8uNCyJWKhEAwSTDJ3NNc07fUsE76J1FjjcL5VQb0O4XBAVCoqj0ZV3u2qvN+H8Psx"
    + "1HLAZsPn6u6pFIQsi3AYYjKBcDpVXiyqPrl2O2ayZqc+FY9jaooZuZwSJBJL8iKv1SwONdTSIJtO"
    + "w1g1GA4h9vfVk3mjod5mPLY4ySQMqT2kgZ0jsMjZBgOL9D1omM2qtfwmH1K7SwN4vbhnkzuQ0G5v"
    + "imnOHjkMjwePC7HGUSajxuDM1aqa/+wM4vJSCRnmHSkU8CwNjrVWIRDAVauFubnjaATRbCoD7m7W"
    + "Ox3Mg0HcaNkaduV9GPCmbbuNrLEnxXeSuzi+reD/wJ+Hx1Qu443BNWvsadqfwDOu6lic9yaAL2uK"
    + "Y4RMd4E2AAAAAElFTkSuQmCC"));
startActivity(Intent.createChooser(share, getString(R.id.menu_share)));

My goal is to enable my application to share dynamically created images without writing to storage. Is there a way to do this?

resolvent:

No, because action_ Send does not use URI. It uses extra_ Text or extra_ STREAM.

Create a ContentProvider to provide the file, and then point the URI to your provider in extra_ Files in stream. You can use custom permissions to protect providers and allow sending activities through flag_ GRANT_ READ_ URI_ Permission accesses it temporarily, although I only try to use the intent structure of the actual URI (for example, SetData ()) instead of using extra like extra_ STREAM.

This sample project uses action_ View demonstrates this technology (Note: you need a device with a PDF viewer to really work)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>