Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Catch error msg return from intent actionview抱歉,无法播放此视频_Android_Video - Fatal编程技术网

Android Catch error msg return from intent actionview抱歉,无法播放此视频

Android Catch error msg return from intent actionview抱歉,无法播放此视频,android,video,Android,Video,下面是我的代码 Intent intent = new Intent(Intent.ACTION_VIEW); File file = new File(SDCardRoot,filename); intent.setDataAndType(path, "video/quicktime"); try { startActivity(intent); } catch (ActivityNotFoundException ex) { } 您知道如何在不

下面是我的代码

Intent intent = new Intent(Intent.ACTION_VIEW);
File file = new File(SDCardRoot,filename);
intent.setDataAndType(path, "video/quicktime");
try { 
     startActivity(intent);         
} 
     catch (ActivityNotFoundException ex) { 
} 

您知道如何在不显示的情况下捕获msg吗?对不起,当我尝试播放mov文件格式并替换为我自己的句子以打开错误时,无法播放此视频。

您当前捕获的是“ActivityNotFoundException”,因此无法捕获其他异常。您必须将ActivityNotFoundException更改为更通用的内容(例如“Exception”),或者添加另一个catch子句

解决方案1:

try { 
    startActivity(intent);         
} 
    catch (Exception ex) { 
} 
解决方案2:

try { 
    startActivity(intent);         
} 
catch (ActivityNotFoundException ex) { 
} 
catch (...<insert your particular exception type here>...) {

}
试试{
星触觉(意向);
} 
捕获(ActivityNotFoundException ex){
} 
捕获(……){
}

您到底遇到了什么问题?你已经试过了。我假设quesion中的错误确实是由startActivity引发的,所以只需在catch部分显示一个toast或对话框。当视频显示error msg但catch无法捕获它时。这就是我面临的问题。