Android Question getInstalledPakages without system apps

DonManfred

Expert
Licensed User
Longtime User
how can get installed pakages without system apps like the method in PakageManager class
Like which method? I dont know a method in packagemanager who get a list without systemapps!? I do just know the method to get allinstalledapps.
 
Upvote 0

mohsen nasrabady

Active Member
Licensed User
Longtime User
thnx
it is not work in all device?
this work for me
B4X:
Sub GetInstalledPackages As List
Dim Obj1, Obj2, Obj3 As Reflector
   Dim size, i, flags As Int
   Dim msg, name As String
   Dim pl As List
   pl.Initialize
   Obj1.Target = Obj1.GetContext
   Obj1.Target = Obj1.RunMethod("getPackageManager") ' PackageManager
   Obj1.Target = Obj1.RunMethod2("getInstalledPackages", 0, "java.lang.int") ' List<PackageInfo>
   size = Obj1.RunMethod("size")
   For i = 0 To size -1
      Obj2.Target = Obj1.RunMethod2("get", i, "java.lang.int") ' PackageInfo
      name = Obj2.GetField("packageName")
      Obj3.Target = Obj2.GetField("applicationInfo") ' ApplicationInfo     
      flags = Obj3.GetField("flags")  
               If Bit.AND(flags, 1)  = 0 Then
                   'app is not in the system image
                msg = msg & name & " : " & flags & CRLF
                pl.Add(name)
               End If     
     
   Next  
   Return pl
End Sub
 
Last edited:
Upvote 0

udg

Expert
Licensed User
Longtime User
It should work.
See here, it refers to API 1 and shows no notes about subsequent deprecation.
 
Upvote 0
Top