I did succeded to read all the installed packages and get then the application lable using package manager ... problem is that reading all labels take a lifetime ...
If the time is not critical then it should be no problem diplaying all but sometimes 5,6 seconds is a lifetime.
Is there any way to fasten this process ?
If the time is not critical then it should be no problem diplaying all but sometimes 5,6 seconds is a lifetime.
Is there any way to fasten this process ?
B4X:
Dim appl As List
appl.Initialize
appl=getLauncherApplications
for i=0 to appl.size-1
dim plabel ,pname as string
pname=appl.get(i)
plabel=pm.GetApplicationLabel(pname) 'where pm is package manager
next
Sub getLauncherApplications As List
Dim intnt As Intent
Dim ref As Reflector
Dim lst As List
Dim result As List
intnt.Initialize(intnt.ACTION_MAIN, "")
intnt.AddCategory("android.intent.category.LAUNCHER")
ref.Target = getPackageManager
'public abstract List<ResolveInfo> queryIntentActivities(Intent intent, int flags)
Dim args(2) As Object
Dim types(2) As String
args(0) = intnt
args(1) = 0
types(0) = "android.content.Intent"
types(1) = "java.lang.int"
lst = ref.RunMethod4("queryIntentActivities", args, types) 'List<ResolveInfo>
result.Initialize
For Each resolveInfo As Object In lst
ref.Target = resolveInfo
ref.Target = ref.GetField("activityInfo")
result.add(ref.GetField("applicationInfo"))
Next
Return result
End Sub