ActivityNotFoundException: No Activity found to handle Intent

代码如下:

Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(filePath)), type);
context.startActivity(intent);

 

异常信息提示如下:

03-20 16:46:48.760: E/AndroidRuntime(30325): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///storage/sdcard0/e-books/Books/book/课堂/PPT/第2章 移动终端.ppt typ=application/vnd.ms-powerpoint flg=0x10000000 }

经过:在有的手机,可以打开ppt文件,在我自己的手机打不开,调试后发现上面的错误信息。

原因:手机没有安装可以打开ppt文件的应用,会出现上面的问题。

解决方法:为了避免有的手机没有安装打开相应文件的应用,应该在startActivity那里做一个try catch,弹出一个toast做提示

 

 

posted @ 2014-03-20 17:01  BaronZ  阅读(5122)  评论(0编辑  收藏  举报