How to open pdf file on Android 6



  • In the manifest, permission is given

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    In the 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 way to the file is right. This code works on versions below 6, and in the sixth instant, pdf file opens and turns it down, 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 there's any idea about this, please speak.



  • The logs are written.

    java.io.FileNotFoundException: Permission denied

    So it's either that the reading programme pdf does not support android 6 or that another way is needed for android 6.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2