简体   繁体   中英

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).

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.

¿Does the default Android Video Player responds the intent with some data? ¿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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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