Skip to content Skip to sidebar Skip to footer

How To Open Pdf File From Internal Storage In Pie?

I try to open PDF file in Pie? but it does not open. I don't get any error. What is the issue? PDF file does not open. Only black screen is shown. In logcat no errors show. What is

Solution 1:

File dwldsPath = new File((Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "test.pdf"));`enter code here`
                    byte[] pdfAsBytes = Base64.decode(content, 0);
               `enter code here`     FileOutputStream os;
                    os = new FileOutputStream(dwldsPath, false);
                    os.write(pdfAsBytes);
                    os.flush();
                    os.close();
                    if (dwldsPath.exists()) {
                        Uri path = Uri.fromFile(dwldsPath);
                        Intent intent = new Intent(Intent.ACTION_VIEW);
                        intent.setDataAndType(path, "application/pdf");
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        // If requesting from a fragment...
                        this.startActivity(intent);
                        return;
                    }

Post a Comment for "How To Open Pdf File From Internal Storage In Pie?"