简体   繁体   English

Android 从 url 分享 pdf

[英]Android share pdf from a url

I have a url with a pdf file and i would like to show a share via intent on button click我有一个 url 和一个 pdf 文件,我想通过点击按钮的意图显示一个共享

SO i have the following所以我有以下内容

 string pdfurl = "http://www.africau.edu/images/default/sample.pdf";

SO in my code i have所以在我的代码中我有

public function showShareIntent(String url){
   Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("application/pdf");

     //attach pdf here
    sendIntent.putExtra(Intent.EXTRA_STREAM, pdfurl);
    startActivity(Intent.createChooser(sharingIntent, "Share sample item via"));

 }

But the above doesnt attach the pdf file但是上面没有附上pdf文件

What am i missing out I have checked on This link but it expains loading this when file is located on local device.我错过了什么我已经检查过这个链接但是当文件位于本地设备上时它会加载它。

How do i attach a url pdf file when showing share.显示共享时如何附加 url pdf 文件。

Step #1: Download the PDF.步骤 #1:下载 PDF。

Step #2: Share it using FileProvider via EXTRA_STREAM .步骤#2:通过EXTRA_STREAM使用FileProvider共享它。

That way, you follow the documentation and use a content: Uri .这样,您就可以按照文档并使用content: Uri

Alternatively, include the URL in some message in EXTRA_TEXT .或者,在 EXTRA_TEXT 的某些消息中EXTRA_TEXT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM