是否可以使用android意图打开远程pdf内容

时间:2013-10-15 11:28:24

标签: android pdf android-intent

我想使用android intent打开托管在远程服务器(类型为pdf)上的文件。这是我当前打开本地文件的代码:

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

如何更改此项以打开远程pdf文件?

1 个答案:

答案 0 :(得分:1)

您可以使用以下代码。请在网址中进行必要的更改

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