我正在编写一个 Android 应用程序来在设备上显示 pdf 文件。我需要使用 Adobe Reader 的当前版本代码 (35498) 来显示 pdf 文件。我有代码在屏幕上显示文件列表。现在我需要调用每个文档的 Adobe 阅读器(而不是设备上安装的任何其他 pdf 阅读器)。我不确定我是如何编码的。我是安卓新手。任何帮助将不胜感激。
提前致谢, 纳文
最佳答案
我看到您想专门打开 Adobe,但您可能想考虑以更类似于 Android 的方式打开一般 Intent 并允许用户选择打开方式。作为引用,您可以使用以下代码执行此操作:
private void openFile(File f, String mimeType)
{
Intent viewIntent = new Intent();
viewIntent.setAction(Intent.ACTION_VIEW);
viewIntent.setDataAndType(Uri.fromFile(file), mimeType);
// using the packagemanager to query is faster than trying startActivity
// and catching the activity not found exception, which causes a stack unwind.
List<ResolveInfo> resolved = getPackageManager().queryIntentActivities(viewIntent, 0);
if(resolved != null && resolved.size() > 0)
{
startActivity(viewIntent);
}
else
{
// notify the user they can't open it.
}
}
如果您确实需要专门使用 Abode Reader 和特定版本,则需要使用 PackageManager.getPackageInfo(String, int)
查询它
关于android - 从我的 Android 应用程序中调用 Adobe Reader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5113435/