无法在Android上打开PDF文件

我正在使用此代码在下载文件夹中打开PDF文件

public void open_pdf(View view) {
    String fileName ="2019_10_22_03_37_25_pm5906.pdf";

    File pdfFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
            + File.separator + fileName);
    Uri path = Uri.fromFile(pdfFile);
    Intent pdfIntent = new Intent(Intent.actION_VIEW);
    pdfIntent.setDataAndType(path,"application/pdf");
    pdfIntent.setflags(Intent.flaG_actIVITY_CLEAR_TOP);
    Toast.makeText(this,"hello: "+pdfFile,Toast.LENGTH_SHORT).show();

    t1 =  findViewById(R.id.textView);
    t1.setText(path.toString() + "####"+pdfFile.getPath());
    try{
        startactivity(pdfIntent);

    }catch(activityNotFoundException e){
        Toast.makeText(this,"No Application available to view PDF",Toast.LENGTH_SHORT).show();
        t1.setText("No applicatoin available");
    } catch ( Exception e){
        Toast.makeText(this,"No App found,sorry",Toast.LENGTH_SHORT).show();
    } finally {
        Toast.makeText(this,"This is finally block",Toast.LENGTH_SHORT).show();
    }
}

有几个问题

  1. PDF文件未打开,URI = file:///storage/emulated/0/Download/2019_10_pm.pdf似乎很合适

  2. 没有异常被调用,也没有错误。

可能是什么问题?我是Android编程的新手

wenpc007 回答:无法在Android上打开PDF文件

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3135994.html

大家都在问