Android Question How to read a package name of any app ?

amorosik

Expert
Licensed User
I would like to use the following code to start a secondary app

B4X:
Dim pm As PackageManager
Dim in As Intent
in.Initialize("","")
in=pm.GetApplicationIntent(Nome_Package_App_Secondaria)

but i don't know the name of the app package to start
The question is: given a certain app installed on an Android device, how to know the package name of that app?
 

amorosik

Expert
Licensed User
I thank those who posted tips and leave the code for those who need it in the future

B4X:
Dim ctxt As JavaObject:   ctxt.InitializeContext
Dim jpm As JavaObject = ctxt.RunMethod("getPackageManager", Null)
Dim PackM As PackageManager
Dim count As Long=1
For Each package As String In PackM.GetInstalledPackages
    Dim ApplicationInfo As JavaObject = jpm.RunMethod("getApplicationInfo", Array(package, 0))
    Log(count & "  Nome:"  & PackM.GetApplicationLabel(package) & "  Package:" & package & "  Apk:" & ApplicationInfo.GetField("publicSourceDir") )
    count=count+1
    Next
 
Upvote 0
Top