Android Question How to get services infos

LucaMs

Expert
Licensed User
Longtime User
From Stackoverflow:

You can enumerate all packages and retrieve their services:
B4X:
List<PackageInfo> pkgs = getPackageManager().getInstalledPackages(PackageManager.GET_SERVICES);
for(PackageInfo pkg : pkgs) {
  // You can now use pkg.services
}


How to do it with b4a?

An explanation of the code would also be useful for those who, like me, do not "chew" Java.

I suppose...

List<PackageInfo> is like VB.Net List Of([Type]) and pkgs is declared as this kind of List.

for(PackageInfo pkg : pkgs) is like b4a:
For Each pkg As PackageInfo In pkgs
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim PackageManager As JavaObject = ctxt.RunMethod("getPackageManager", Null)
Dim packages As List = PackageManager.RunMethod("getInstalledPackages", Array(0x00000004))
For Each pck As JavaObject In packages
   Log(pck)
Next
 
Upvote 0
Top