Monday, January 16, 2012

Get installed Applications with Details

AIM:  To retrieve all installed apps with the application name, package name, version-number and -code as well as the icons.
Classes:  method getPackages() returns an ArrayList with all the apps.
Code snippet:

class PackageInfoData{
    private String appname = "";
    private String pname = "";
    private String versionName = "";
    private int versionCode = 0;
    private Drawable icon;

private void getInstalledPackages() {
    ArrayList<PackageInfoData> installedApps = getInstalledApps(false); /* false = no system packages */
    for (int i=0; i<installedApps.size(); i++) {
       Log.i("Instlled app","APp Name:"+installedApps.get(i).appname+"package:"+installedApps.get(i).pname);
    return installedApps ;

private ArrayList<PackageInfoData> getInstalledApps(boolean getSysPackages) {
    ArrayList<PackageInfoData> res = new ArrayList<PackageInfoData>();       
    List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
    for(int i=0;i<packs.size();i++) {
        PackageInfo p = packs.get(i);
        if ((!getSysPackages) && (p.versionName == null)) {
            continue ;
        PackageInfoDatanewInfo = new PackageInfoData();
        newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
        newInfo.pname = p.packageName;
        newInfo.versionName = p.versionName;
        newInfo.versionCode = p.versionCode;
        newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
    return res;


  1. Thanks for a marvelous posting! I quite enjoyed reading
    it, you may be a great author.I will remember to bookmark your blog and will come back in the future.

    I want to encourage you continue your great posts, have a nice

    Also visit my blog :: rozliczenie pit 2014 ()

  2. Greetings from Idaho! I'm bored to death at work so I decided
    to check out your blog on my iphone during lunch break. I enjoy the info you present here and can't
    wait to take a look when I get home. I'm shocked at how quick your blog loaded on my cell phone ..

    I'm not even using WIFI, just 3G .. Anyhow, superb blog!

    Feel free to surf to my weblog: making money online

  3. Hello my family member! I want to say that this post is awesome,
    nice written and come with almost all vital infos. I would like to look more
    posts like this .

    Take a look at my web page; lattenrost test

  4. I feel that is one of the so much significant information for me.
    And i'm happy studying your article. However want to statement
    on some general issues, The web site taste is great, the articles is
    really great : D. Good job, cheers

    Here is my weblog; hurricane impact windows


Android Developers Blog

Ram's shared items