如何通过按下按钮打开PDF?

cri*_*ndu -1 java pdf android

我正在制作一个Android应用程序,对那些想要获得驾驶执照的人有用,但我不知道如何做到以下几点:我有主要的活动.现在,通过按下急救按钮,我想用急救说明来附上文本或pdf.基本上我想对机械和立法做同样的事情.对不起我的英语,这不是我的第一语言.

Mad*_*uri 5

对于openinig pdf文件,单击button.put跟随侦听器中的代码.

 String FILE = Environment.getExternalStorageDirectory().getPath()+"/abc.pdf";   

 File file = new File(FILE); 

 //file should contain path of pdf file/
 Uri path = Uri.fromFile(file);
 Intent intent = new Intent(Intent.ACTION_VIEW);
 intent.setDataAndType(path, "application/pdf");
 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

 try {
       startActivity(intent);
     } 
     catch (ActivityNotFoundException e)
     {
            Toast.makeText(this, 
                "No Application Available to View PDF", 
                Toast.LENGTH_SHORT).show();
        }
Run Code Online (Sandbox Code Playgroud)