问题描述
我要出货的PDF文件以及我的应用程序,并显示它们的列表,点击时每个人应该在Adobe Reader中打开。我试图把PDF文件在/资产也文件夹中/ RES /原始文件夹中。但在任何情况下,我遇到ActivityNotFound例外。在code和异常信息如下。
I have to ship pdf files along with my application and display them as list and when clicked each one should open in Adobe reader. I have tried placing the pdf files in /assets folder also in /res/raw folder. But in either case I am encountering ActivityNotFound Exception. The code and the exception message are below.
中/资产配售文件/ 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放置文件/文件夹的原始
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 }
任何帮助将是很大的AP preciated。
Any help would be greatly appreciated.
在此先感谢,纳文
推荐答案
如果你得到一个 ActivityNotFoundException
是因为没有应用程序来处理该类型的内容。因此,在这种情况下,我敢肯定安装了Adobe Reader中。
If you get an ActivityNotFoundException
is because there are no application to handle that kind of content. So, in that case, I'm sure the the Adobe Reader is installed.
另外,我觉得你必须将文件复制到SD卡的其他应用程序来访问它。他们不能直接访问您的私人数据安全方面的原因。
Also, I think you must copy the file to the SDCard for other apps to access it. They cannot access your private data directly for security reasons.
这篇关于读取文件中的资产或原始文件夹中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!