我正在使用 itext7 開發一個 android 應用程式,只有在重新啟動設備后才能找到生成的 pdf 檔案
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString();
File file = new File(path , "attestation.pdf");
OutputStream outputStream = new FileOutputStream(file);
PdfWriter writer = new PdfWriter(file);
PdfDocument pdfDocument = new PdfDocument(writer);
Document document = new Document(pdfDocument);
Paragraph paragraph = new Paragraph("Hello world ! ");
document.add(paragraph);
document.close();
uj5u.com熱心網友回復:
我認為您必須先更新媒體庫,然后其他應用才能“看到”它。
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(newMediaFile)));
通常在重啟時媒體庫會自動更新,因此只需簡單的重啟就可以讓其他應用程式“看到”這個檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/418399.html
標籤:
