可以通过原生Android应用程序打开远程pdf文件?

时间:2015-04-30 18:16:16

标签: java android pdf

我想通过Android设备上安装的本机应用程序打开远程pdf文件。那可能吗 ? 我尝试使用mime类型的intent,但这不起作用。我不想使用docs.google.com参考。

有什么建议吗?

对于参考。 :

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

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(<remote_pdf>), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

1 个答案:

答案 0 :(得分:0)

前段时间我需要像你说的那样实施。我的客户对docs.google.com网址不满意,我找到的替代方法是将远程pdf下载到设备(在公共文件夹中,如外部存储),并启动本地Uri的意图已下载的pdf。否则,如果用户没有安装任何pdf阅读器,我会使用pdf的url启动doc.google.com网址,但在某些特殊情况下会启动此问题。

PD:如果您使用此方法,请确保将文件下载到公共目录中,否则pdf阅读器将无法打开它。

此致