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

Discussion in 'Android Questions' started by cambopad, Mar 5, 2015.

  1. cambopad

    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 :


    Code:
    public Drawable getApkIcon(String path){   
        
    PackageManager pm = getPackageManager();   
        PackageInfo info = pm.getPackageArchiveInfo(
    pathPackageManager.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 :)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use the new inline java feature to run this code.

    Add the following imports at the beginning of the Java code:
    Code:
    import android.content.pm.ApplicationInfo;
    import android.content.pm.PackageInfo;
    import android.content.pm.PackageManager;
    import android.graphics.drawable.Drawable;
    import android.os.Build;
     
    cambopad likes this.
  3. peacemaker

    peacemaker Well-Known Member Licensed User

    Code:
    Dim pm As PackageManager 'Phone lib 
    pm.GetApplicationIcon
    pm.GetApplicationLabel
    pm.GetVersionName
    pm.GetVersionCode
    ?
     
    cambopad likes this.
  4. DonManfred

    DonManfred Expert Licensed User

    Questions?
     
    cambopad likes this.
  5. peacemaker

    peacemaker Well-Known Member Licensed User

    Oh, endeed, sorry, my fault, did not notice that about separate APK.
     
    DonManfred likes this.
  6. cambopad

    cambopad Active Member Licensed User

    This is my question :D :

    Thanks you!
     
  7. DonManfred

    DonManfred Expert Licensed User

    I dont know a way. But my questions does not meant to you
     
  8. diegoferreira

    diegoferreira Member Licensed User

    You solved? I need !
     
  9. DonManfred

    DonManfred Expert Licensed User

    No one solved because there is no way. At least i dont know a way...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice