Android share pdf from a url



>我有一个带有pdf文件的网址,我想通过点击按钮的意图显示共享

所以我有以下内容

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

所以在我的代码中我有

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"));
}

但以上没有附加 pdf 文件

我错过了什么 我已经检查了此链接,但是当文件位于本地设备上时,加载此链接会很痛苦。

如何在显示共享时附加 url pdf 文件。

步骤#1:下载PDF。

步骤#2:通过EXTRA_STREAM使用FileProvider共享它。

这样,您就可以按照文档进行操作并使用content:Uri.

或者,在EXTRA_TEXT中的某些消息中包含 URL。

最新更新