I have been using similar code to get the list of applications and application icons and it worked ok, until I upgraded the phone to Lollipop.
Now I get an error on line Dim bdw As BitmapDrawable = pm.GetApplicationIcon(p): "java.lang.ClassCastException: android.graphics.drawable.VectorDrawable cannot be cast to android.graphics.drawable.BitmapDrawable". When the error is dismissed, it still displays the icon in the listview OK OK.
You dont need reflector for this. Just add Phone library
B4X:
Activity.LoadLayout("Layout1")
lv.Clear
Dim pm As PackageManager
Dim packages As List
packages = pm.GetInstalledPackages
For i = 0 To packages.Size - 1
Dim p As String = packages.Get(i)
Dim bdw As BitmapDrawable = pm.GetApplicationIcon(p)
lv.AddTwoLinesAndBitmap(pm.GetApplicationLabel(p),packages.Get(i),bdw.Bitmap)
Log(packages.Get(i))
Next
Thanks Erel. I looked for the package name "com.android.systemui" and skipped it when it was in the the loop. But it will be safer to use try-catch as you suggested, just in case (in future) there are other applications with this problem.