我得到了这个异常
06-28 21:00:48.792: W/System.err(10272): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/01 - 3G - Kaise Bataaoon [SongsPK.info] (2).mp3 typ=audio/mpeg }我正在尝试通过以下代码打开此文件:
File sdCard = Environment.getExternalStorageDirectory();
Intent intnt = new Intent(Intent.ACTION_VIEW);
String ext = fileToOpen.substring(fileToOpen.lastIndexOf('.')+1) ;
//Intent j = Intent.createChooser(intnt, "Choose an application to open with:");
//startActivity(j);
File fl = new File(sdCard.getAbsolutePath()+"/"+ fileToOpen);
if(fl.exists())
{
Log.d("FILEMANAGERACTIVITY",fl.getPath() + "0"+ ext);
MimeTypeMap mim = MimeTypeMap.getSingleton();
String type= mim.getMimeTypeFromExtension(ext);
intnt.setDataAndType(Uri.fromFile(fl) , type);
startActivity(intnt);
}发布于 2013-06-29 00:18:56
确保您在intnt.setDataAndType(Uri.fromFile(fl) , type);中发送的数据和类型是正确的,看起来Intent.ACTION_VIEW与该意图数据没有任何匹配,因此没有活动来处理该意图……
致以问候!
发布于 2013-06-29 00:48:10
将活动添加到mainfist.xml可能会对您有所帮助
https://stackoverflow.com/questions/17369183
复制相似问题