zoukankan      html  css  js  c++  java
  • 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做提示

  • 相关阅读:
    Python连接MySQL乱码(中文变问号)
    mysql学习04 pymysql 学习
    mysql学习03
    多态与多态性
    重用父类功能的两种方式
    菱形继承问题
    组合
    继承的应用和派生的概念引出
    类的继承
    类与类型
  • 原文地址:https://www.cnblogs.com/baron89/p/3614138.html
Copyright © 2011-2022 走看看