I use the below code to display the package name and the label name, but I would like to also show the corresponding apk file name. Is there an easy way to extract it or perhaps use javaobject or reflection?
B4X:
Dim pm As PackageManager 'need phone library
For Each package As String In pm.GetInstalledPackages
If package.Contains("div")Then
Log(pm.GetApplicationLabel(package))
Log(package)
Log("apk file name:") 'Need to extract the corresponding apk file name here
Log("-----------")
End If
Next
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim jpm As JavaObject = ctxt.RunMethod("getPackageManager", Null)
Dim pm As PackageManager
For Each pck As String In pm.GetInstalledPackages
Dim ApplicationInfo As JavaObject = jpm.RunMethod("getApplicationInfo", Array(pck, 0))
Log($"Package: ${pck}, Path: ${ApplicationInfo.GetField("publicSourceDir")}"$)
Next
I attached a small project that demonstrates the behavior where the apk file name repeats itself for several of the packages installed on the device. Perhaps, some of the members can also test this tiny project and see if they can tweak it to get it to work properly or confirm that it is not doable.
Thank you
Thanks @Geezer for testing. I have tested it in 2 devices. One with OS 6.0.1 and one with 8.1 and I still have the same problem. Stroll down the logs, you will see in many packages the same apk name is shown for non system apps.
As far as the div, it is designed for me to display certain particular packages that have the word div in them. That is why I commented that line in the exported project.
Ok. That is what I found too. all apk are: base.apk. I am still at a loss why there is no solution to this. There is a good reason why I wanted this feature.