简体   繁体   English

是否可以使用Android Intent打开远程PDF内容

[英]Is it possible to open remote pdf content using an android intent

I want to open a file hosted on a remote server (of type pdf) using an android intent. 我想使用Android Intent打开托管在远程服务器(类型为pdf)上的文件。 This is the code that i have currently that opens a local file: 这是我当前打开本地文件的代码:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(<local_path>));
intent.setType("application/pdf");
PackageManager pm = getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
if (activities.size() > 0) {
    startActivity(intent);
}

How can i change this to open a remote pdf file ? 我该如何更改以打开远程pdf文件?

You can use the following code. 您可以使用以下代码。 Kindly make necessary changes in the url 请在网址中进行必要的更改

Intent i=new Intent(Intent.ACTION_VIEW);
String link="http://docs.google.com/gview?embedded=true&url=" + "http://www.yoursite.com/downloads/yourpdf.pdf";
i.setData(Uri.parse(link));
startActivity(i);

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

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