アプリケーションと一緒にPDFファイルを出荷し、リストとして表示する必要があります。クリックすると、各ファイルがAdobeReaderで開きます。pdfファイルを/res/rawフォルダーにもある/assetsフォルダーに配置してみました。しかし、どちらの場合でも、ActivityNotFound例外が発生しています。コードと例外メッセージは以下のとおりです。
ファイルを/assets/pdfフォルダーに配置します
try {
files = amanager.list("pdf");
//AssetFileDescriptor fd = amanager.openFd(files[0]);
Uri path = Uri.parse("android.resource://com.csg.android.myproject/assets/pdf/csgsample") ;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.adobe.reader");
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e){
Toast.makeText(FirstTab.this, "NO Viewer", Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/ res/rawフォルダーにファイルを配置する
Uri.parse("android.resource://com.csg.android.myproject/raw/csgsample") ;
例外:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.csg.android.myproject/assets/pdf/csgsample typ=application/pdf flg=0x4000000 pkg=com.adobe.reader }
どんな助けでも大歓迎です。
よろしくお願いします、Navin