Android Question how to GetProviderName of installed package

Alex Steinmetz

Member
Licensed User
B4A, I am suppling the end user a list of installed applications (without system).
but I need also to supply the name of the provider.

B4X:
Sub popPack
    Dim obj1, obj2, obj3 As Reflector
    Dim size, flags As Int
    Dim name, label As String
    obj1.Target = obj1.GetContext
    obj1.Target = obj1.RunMethod("getPackageManager") 'packageManager
    obj1.Target = obj1.RunMethod2("getInstalledPackages", 0, "java.lang.int") 'List packages
    size = obj1.RunMethod("size")
    Dim y As Int = 0
    For i = 0 To size - 1
        obj2.Target = obj1.RunMethod2("get", i, "java.lang.int") 'package info.
        name = obj2.GetField("packageName")
        obj3.Target = obj2.GetField("applicationInfo") 'application Info.
        flags = obj3.GetField("flags")
        Dim x As String = flags
        If Bit.And(flags, 1) = 0 And x.StartsWith(9) Then 'app is not in system image
           Dim pm As PackageManager         'phone library
           label = pm.GetApplicationLabel(name)
           myspin(y) = label
           y = y + 1
        End If
    Next
End Sub
 
Upvote 0
Top