简体   繁体   English

从意图调用的外部应用程序/活动中捕获错误/异常

[英]Catch error / exception from intent-called external application / activity

Let's say I have an application with an activity which list a bunch of files. 假设我有一个活动列出了一堆文件的应用程序。 When the user touch one of this files an ACTION_VIEW intent with proper mimeType and stuff is triggered so Android will prompt the user to choose one of the video players installed in the system (or the one that's defaulted). 当用户触摸其中一个文件时,会触发具有正确mimeType和stuff的ACTION_VIEW意图,因此Android将提示用户选择安装在系统中的一个视频播放器(或默认的视频播放器)。

I'm wondering if there is a way of telling if the playback of the file itself succeded or not. 我想知道是否有办法告诉文件本身的播放是否成功。 Because if I detect there was an error I can recomend the user other players available on Google Play. 因为如果我发现有错误,我可以向用户推荐Google Play上的其他玩家。

¿Does the default Android Video Player responds the intent with some data? ¿默认的Android视频播放器是否使用某些数据响应意图? ¿Is there some generalized, common or standard way to get this information? ¿是否有一些通用的,通用的或标准的方式来获取这些信息?

Any data on the subject is appreciated. 有关该主题的任何数据表示赞赏。

Thanks in advance. 提前致谢。

I'm wondering if there is a way of telling if the playback of the file itself succeded or not. 我想知道是否有办法告诉文件本身的播放是否成功。

You can tell if there was any eligible activity for the ACTION_VIEW Intent , either by catching ActivityNotFoundException on your startActivity() call, or by calling queryIntentActivities() ahead of time and checking for an empty list. 您可以通过在startActivity()调用上捕获ActivityNotFoundException ,或者通过提前调用queryIntentActivities()并检查空列表来判断ACTION_VIEW Intent是否有任何符合条件的活动。

Once control passes to the third-party activity, that activity is like Las Vegas: what happens in that activity stays in that activity. 一旦控制转移到第三方活动,该活动就像拉斯维加斯:该活动中发生的事情会保留在该活动中。 You have no way of knowing anything about what went on, in terms of "success" or "failure" or anything else. 在“成功”或“失败”或其他任何方面,你无法知道发生了什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM