我感謝你的幫助,使我的代碼可以打開一個PDF文件,意圖,這是我一直在使用的代碼:如何在Android Nougat中使用Intent打開PDF文件?
String pathFile =
Environment.getExternalStorageDirectory().toString() +
FileUtils.PATH_SEPARATOR + "myFolder" +
FileUtils.PATH_SEPARATOR + "myFile.pdf";
File pdfFile = new File(pathFile);
if (pdfFile.exists()) {
Uri uri = Uri.fromFile(new File(pathFile));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "application/pdf");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
但據我所知,現在(從Android-N版)的特權處理方式不同,所以我希望你能通過指出我必須做出什麼改變來獲得使用Intent打開的PDF文件來幫助我。
PS:在我的AndroidManifest.xml我正在尋找在存儲的所有權限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
您是否允許讀取外部存儲? – Karthik
我在我的AndroidManifest.xml上有關於存儲的權限請求 – Pepo
您是否聲明瞭運行時權限,因爲從nogout開始,我們需要聲明運行時權限。 – Karthik