I am trying to open an pdf document which resides in res/raw folder.when clicking on the button it shows the screen as follows
.
I am not sure why is this showing like this…
Please let me know and thanks …
Please find my code as below
Button MyRawBtn = (Button)findViewById(R.id.buttonId2);
MyRawBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
Toast.makeText(MainActivity.this,
"ImageButton (selector) is clicked!",
Toast.LENGTH_SHORT).show();
File pdfFile = new File("res/raw/sample.pdf");
Uri path = Uri.fromFile(pdfFile);
//Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.sample);
//File file = new File(uri.toString());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path,"application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}
});
Please Use below Stack Overflow Answer’s link code for Read PDF using PDFViewer.jar library into your android application and if you have any query regarding that then tell me.
Code to Implement a PDF Reader