In an app, I'm searching if at least one pdf viewer is installed, in order to open pdf files there.
In order to do that I use:
Dim INTENT1 As Intent
INTENT1.Initialize(INTENT1.ACTION_VIEW,pdfFileName)
INTENT1.SetType("application/pdf")
INTENT1.Flags=1
'INTENT1.SetComponent("android/com.android.internal.app.ResolverActivity")
'I can't remember why I remarked the above line, but it's been ages since then
Dim pdfAppsList As List
pdfAppsList = QueryIntent(INTENT1)
If pdfAppsList.IsInitialized=True Then
If pdfAppsList.Size>0 Then
StartActivity(INTENT1)
end if
end if
And the queryIntent sub is:
Sub QueryIntent(Intent1 As Intent) As List
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod("getPackageManager")
Dim list1 As List
list1 = r.RunMethod4("queryIntentActivities", Array As Object(Intent1, 0), Array As String("android.content.Intent", "java.lang.int"))
Dim listRes As List
listRes.Initialize
For i = 0 To list1.Size - 1
r.Target = list1.Get(i)
r.Target = r.GetField("activityInfo")
listRes.Add(r.GetField("packageName"))
Next
Return listRes
End Sub
I never experienced any problem with this coding, not until now that some users complain about my app not recognizing their installed pdf viewer.
In my devices for testing, I coudln't find a problem, so I'm wondering if any of you experienced such thing and (or not) found a way to solve it.
Is it a problem with my code, for e.g. some new weird permissions?