Android Question Launcher Apps - get icon & label

Imam

Member
Licensed User
Longtime User
B4X:
Sub getListAppLauncher
Dim in1 As Intent
in1.Initialize(in1.ACTION_MAIN, "")
in1.AddCategory("android.intent.category.LAUNCHER")
Dim pm As PackageManager
Dim lst As List
Dim icn As BitmapDrawable
Dim nma As String
lst = pm.QueryIntentActivities(in1)
For Each cn As String In lst
Dim s() As String
s = Regex.Split("/", cn)
Log(cn)
icn = pm.GetApplicationIcon(s(0))
nma = pm.GetApplicationLabel(s(0))
listview1.AddTwoLinesAndBitmap2(nma, cn, icn.Bitmap, cn)
Next
End Sub

Sub listview1_ItemClick (Position As Int, Value As Object)
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_MAIN, "")
Intent1.SetComponent(Value)
StartActivity(Intent1)
End Sub

how to get label and icon application.
 

Imam

Member
Licensed User
Longtime User
I want to get the icons and labels on the gallery and camera . it only found the camera icon and label
 

Attachments

  • tes.png
    tes.png
    114.4 KB · Views: 389
Upvote 0

Imam

Member
Licensed User
Longtime User
how to get icon and label from this intent?

com.android.contacts/.activities.PeopleActivity
com.minirom.clock/com.android.deskclock.DeskClock
com.minirom.camera/com.android.gallery3d.app.Gallery

please help me @Erel
 
Upvote 0

Imam

Member
Licensed User
Longtime User
B4X:
    public static Drawable getIconDrawable(PackageManager packageManager, ApplicationInfo info) {
        final ResolveInfo resolveInfo = packageManager.resolveActivity(info.intent, 0);
        if (resolveInfo == null) {
            return null;
        }
        ComponentName componentName = new ComponentName(
                resolveInfo.activityInfo.applicationInfo.packageName,
                resolveInfo.activityInfo.name);
        ApplicationInfo cached;
        synchronized (sCache) {
            cached = sCache.get(componentName);
            if (cached != null) {
                if (cached.icon == null) {
                    cached.icon = resolveInfo.activityInfo.loadIcon(packageManager);
                }
                return cached.icon;
            } else {
                return resolveInfo.activityInfo.loadIcon(packageManager);
            }
        }
    }
 
Upvote 0
Top