chandanmahajan
Lurker
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();
}
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.
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();
}
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.
