Android Question Get Icon, Application Name, and Version name of APK files on SD card

cambopad

Active Member
Licensed User
Dear all B4A devs!

How can I get all of the information such as icon, application name, and version name of the APK files (which are NOT already installed) stored on the SD card. I googled and found some answers on Stackoverflow, but unable to convert it to b4a as I know nothing about Java. This is the sub in Java to get the Icon :


B4X:
public Drawable getApkIcon(String path){   
    PackageManager pm = getPackageManager();   
    PackageInfo info = pm.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES);   
    if(info != null){   
        ApplicationInfo appInfo = info.applicationInfo;

        if(Build.VERSION.SDK_INT >= 8){
            appInfo.sourceDir = path;
            appInfo.publicSourceDir = path;
        }

        return appInfo.loadIcon(pm);
    }        
    return null;
}
Can anyone help to convert this to B4a?

Thanks you :)
 

peacemaker

Well-Known Member
Licensed User
B4X:
Dim pm As PackageManager 'Phone lib 
pm.GetApplicationIcon
pm.GetApplicationLabel
pm.GetVersionName
pm.GetVersionCode
?
 
Top