从服务器获取pdf文件并在android中的pdf viewer中显示

时间:2013-07-26 02:37:27

标签: android

我正在开发Android应用程序。我在ftp服务器上有我的pdf文件。现在我需要使用pdf阅读器在我的Android应用程序中显示它们。那可能吗?我怎样才能做到这一点?请帮助我。

提前谢谢

1 个答案:

答案 0 :(得分:0)

您可以通过FTP下载并将其保存在SD卡上查看how get ftp file with android,这就是您在PDF阅读器中打开它的方法:

PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/pdf");
packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);

Intent pdfintent = new Intent();
pdfintent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(yourfile);
pdfintent.setDataAndType(uri, "application/pdf");
context.startActivity(pdfintent);