Android Question PackageManager, only not system app

delozoya

Member
Licensed User
Longtime User
Hello. I would like if with PackageManager i can select not system app, because I view app as setting... than I do not want to see

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
Assuming you have an Listview in your layout called lv... This will add all NON-system-apps to the listview.

B4X:
Sub populatePackages
    lv.Clear
    Dim Obj1, Obj2, Obj3 As Reflector
  Dim size, i, flags As Int
  Dim name As String
  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
      'Log(name & " : " & flags)
      lv.AddSingleLine(name)
        End If    
  Next 
End Sub
 
Upvote 0
Top