所以想法是我打開一個文件使用已經預裝在設備上的應用程序。 這裏是我的代碼處理意圖視圖typ =音頻/ mpeg
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(fileUri);
intent.setType(mimeType);
startActivity(intent);
我的錯誤信息是
08-25 12:50:32.900: E/AndroidRuntime(19555): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=audio/mpeg }
任何想法如何處理呢?我閱讀了意向過濾器,但是來自這裏的人告訴我,如果我要使用其他應用程序來打開我的文件,那麼我不需要指定任何過濾器,這是真的嗎?
P.S.由於某種原因,它打開PDF文件蠻好的,JPG和TXT
感謝 丹尼斯XX
剛剛完成它 - 我會建議使用intent.setDataAndType而不是intent.setData後跟intent.setType。 – Dennis
@丹尼斯:哦,是的,我完全錯過了。 'setType()'將會清除你傳遞給'setData()'的'Uri'。 – CommonsWare