可能重复:
Intent for editing plain text file with the installed file editor (if any)ActivityNotFound即使活动存在
我试图打开我已经下载了一些文本文件。当我用intent启动活动时,它会给ActivityNotFound异常。
try {
Uri path = Uri.parse(path+"/sampletext.txt");
Intent intent = new Intent(Intent.ACTION_VIEW);
PackageManager packageManager = ctx.getPackageManager();
intent.setType("text/plain") ;
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
intent.setDataAndType(path, "text/plain");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
ctx.startActivity(intent) ;
}
} catch (Exception e){
e.printStackTrace() ;
}
当我调试,我发现,则为list.size为1
有哪些我失踪的任何其他信息?
任何类型的点都会帮助我。
谢谢。
我可以从文件浏览器打开相同的文件,但不能从我的应用程序打开。 – Vinay
@ Merlin我不想编辑文件..我需要打开文件阅读.. – Vinay
这是一样的想法 – Merlin