我創建了一個類openPDF,它將一個字節數組作爲輸入並用Adobe Reader顯示PDF文件。代碼:用Adobe Reader顯示PDF文件
private void openPDF(byte[] PDFByteArray) {
try {
// create temp file that will hold byte array
File tempPDF = File.createTempFile("temp", ".pdf", getCacheDir());
tempPDF.deleteOnExit();
FileOutputStream fos = new FileOutputStream(tempPDF);
fos.write(PDFByteArray);
fos.close();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(tempPDF);
intent.setDataAndType(uri, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} catch (IOException ex) {
String s = ex.toString();
ex.printStackTrace();
}
}
當我經過打算,從Adobe Reader的錯誤是「無效的文件路徑」。我閱讀所有其他帖子有關下載和在Android中查看PDF,但力量幫助很大。有什麼建議麼?
您是否嘗試過將非臨時文件作爲輸入到adobe應用程序? – 2012-09-26 11:37:08