chandanmahajan Posted April 26, 2013 Share Posted April 26, 2013 Hi All,I am very new to android application. Developing one application where I want to open pdf on button click. I am running my application on emulator also on android phone. Could anybody guide me on this? how to achieve this functionality in detail?After searching on google, It seems that we need to create raw folder.Here is the code from the activity class which gets called after button click:File file = new File("android.resource://com.example.hellogridview/raw/test.pdf");if (file.exists()) {Uri targetUri = Uri.fromFile(file);Intent intent = new Intent(Intent.ACTION_VIEW);intent.setDataAndType(targetUri, "application/pdf");try {Toast.makeText(FullImageActivity.this, "in try testing more", Toast.LENGTH_SHORT).show();startActivity(intent);}catch (ActivityNotFoundException e) {Toast.makeText(FullImageActivity.this, "in catchtesting more", Toast.LENGTH_SHORT).show();Toast.makeText(FullImageActivity.this, "No Application Available to View PDF", Toast.LENGTH_SHORT).show();}}else{Toast.makeText(FullImageActivity.this, "file not found", Toast.LENGTH_SHORT).show();} I always get file not found. Could anybody let me know where I should create the raw folder? or if anybody could provide me the sample application which is running successful will be highly appricated. Thanks in Advance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.