可能重複:
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