Permission specified in manifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
In code
file = new File("/storage/emulated/0/Download/ccAlTT_D__.pdf"); Uri uri = Uri.fromFile(file); Intent intentOpenFile = new Intent(Intent.ACTION_VIEW); intentOpenFile.setDataAndType(uri, "application/pdf"); intentOpenFile.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intentOpenFile); The file path is correct. This code works on versions below 6, and in the sixth moment it opens the pdf file and immediately minimizes it, while leaving it in the logs -
12-23 14:06:53.248 18679-16520/? E/DisplayData: openFd: java.io.FileNotFoundException: Permission denied 12-23 14:06:53.248 18679-16520/? E/PdfLoader: Can't load file (doesn't open) Display Data [PDF : ccAlTT_D__.pdf] +UriOpenable 12-23 14:06:53.381 881-896/? E/KernelCpuSpeedReader: Failed to read cpu-freq: /sys/devices/system/cpu/cpu4/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory) If you have any ideas about this, please speak up.
READ_EXTERNAL_STORAGE? - YurySPb ♦В Android 6permissions must be requested. In order not to request permissions, setTarget SDK 22, or lower - Vladyslav MatviienkogetExternalStorageDirectory()does not work, I checked it long ago - Pavel K