I tried using Try/Catch and it works fine.
registered file types (jpg,mp3,txt, pdf etc....) are opened OK (or offering a menu of "open with" apps)
But when the device has the game "250+ Solitaire Collection" then ANY unregisterd type cause this game to launch.
I try to see which apps are available for the type chosen using:
Dim in As Intent
in.Initialize(in.ACTION_VIEW, somefile)
in.Flags = 1
' get apps for this type
Dim applst As List
Dim i As Int
applst.Initialize
Dim pm As PackageManager
applst=pm.QueryIntentActivities(in)
Log("file= " & somefile)
Log("# of apps=" & applst.Size)
For i=0 To applst.Size-1
Log("a " & i & " = " & applst.Get(i))
Next
Try
StartActivity(in)
Catch
ToastMessageShow("No App for " & somefile,True)
End Try
log shows:
------------------------------------------------------------------------
file= ar_200618_092733.jpg <========== .jpg file, good open with menu
# of apps=3
app 0 = com.sec.android.gallery3d/.app.GalleryActivity
app 1 = com.google.android.apps.photos/.pager.HostPhotoPagerActivity
app 2 = com.iudesk.android.photo.editor/app.activity.PhotoViewActivity
file= as.conf <============ .conf (unregisterd file, no app for it)
# of apps=1
app 0 = com.anoshenko.android.solitaires/com.anoshenko.android.ui.LaunchActivity
file= .dinfo <================ .dinfo (unregisterd, no app for it)
# of apps=1
app 0 = com.anoshenko.android.solitaires/com.anoshenko.android.ui.LaunchActivity
--------------------------------------------------------------------
space lines are for clarity.
as you can see, for unregistered type "com.anoshenko.android.solitaires" is fired.
"250+ Solitaire Collection" is published by Alexei Anoshenko.
Any thoughts of why this is happening?
Of course, avoiding this problem is to see if the apps list has 1 app (solitaire) and do not fire the intent if so.
but there might be other apps that causes this. I want to know how to avoid this in any case