File file = new File(s);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
try {
startActivity(intent);
}
catch(Exception e)
{
file.delete();
downloadFile(file);
}
我想在Android中使用外部应用程序打开PDF,如果文件已完全下载,它将打开并显示PDF文件。 如果文件为空或损坏,我想删除文件并重新下载。如何处理无法使用外部应用程序在Android中打开文件
,但我不能处理
例外“的文件无法打开”。
你从哪里看到那个异常?显示堆栈跟踪。 – greenapps
'(s)'。你认为's'的价值是无关紧要的? – greenapps
你的pdf文件位置在哪里?因为它取决于第三方应用程序操作来查看。 –