getPackageManager().getPackageInfo

kanaida

Active Member
Licensed User
Longtime User
After scratching my head for a long time, and googling plenty. I couldn't make what I was trying to make because the b4a package manager class currently gets very basic information, unfortunately exactly missing what I need :( the list of activities and other info in a given package...

I found some java code that looks like the ticket.

B4X:
ActivityInfo[] activityInfo = getPackageManager().getPackageInfo(pack.packageName, PackageManager.GET_ACTIVITIES).activities

If I can get this in there, I can pump out another killer feature on a new app...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim activities() As Object
   activities = GetActivitiesInfo("com.android.browser")
   Dim r As Reflector
   For i = 0 To activities.Length - 1
      r.Target = activities(i)
      Log(r.GetField("name"))
   Next
End Sub

Sub GetActivitiesInfo(package As String) As Object()
   Dim r As Reflector
   r.Target = r.GetContext
   r.Target = r.RunMethod("getPackageManager")
   r.Target = r.RunMethod3("getPackageInfo", package, _
      "java.lang.String", 0x00000001, "java.lang.int")
   Return r.GetField("activities")
End Sub
 
Top