Android Question Detect If Intent Failed

RandomCoder

Well-Known Member
Licensed User
Longtime User
I was intending to use a VideoView in my app but I've found that the supported CODEC's on some devices is very poor and so I'm now using an intent to ask the user to select a pre-installed video player to use. But I was just wondering what would happen if no player was installed? Do I get an error that could be detected and then attempt to load the VideoView instead? I'm thinking that because it's starting a new activity, there will be no error and so no point using Try, Catch and load VideoView?

Does anyone have any experience of this or a device with no player installed and willing to try this code...
B4X:
Try
            Dim i As Intent
            i.Initialize(i.ACTION_VIEW, "this would be a valid path")
            i.SetType("video/*")
            StartActivity(i)
Catch
            MsgBox("No player selected", "ERROR")
End Try
I've tried it in the emulator and it doesn't show the message box but rather another message box saying unable to play video.

Thanks,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
I'd not thought of doing it like that. Thanks for the advice. :D

It's often good to look at a problem from another perspective. Nothing's impossible with at little applied creativity :cool:

Cheers,
RandomCoder
 
Upvote 0
Top