`
marine8888
  • 浏览: 545928 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Get installed Applications with Name, Package Name, Version and Icon

 
阅读更多

class PInfo {  
    private String appname = "";  
    private String pname = "";  
    private String versionName = "";  
    private int versionCode = 0;  
    private Drawable icon;  
    private void prettyPrint() {  
        log(appname + "\t" + pname + "\t" + versionName + "\t" + versionCode + "\t");  
    }  
}  
  
private void listPackages() {  
    ArrayList<PInfo> apps = getInstalledApps(false); /* false = no system packages */  
    final int max = apps.size();  
    for (int i=0; i<max; i++) {  
        apps.get(i).prettyPrint();  
    }  
}  
  
private ArrayList<PInfo> getInstalledApps(boolean getSysPackages) {  
    ArrayList<PInfo> res = new ArrayList<PInfo>();          
    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 ;  
        }  
        PInfo newInfo = new PInfo();  
        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());  
        res.add(newInfo);  
    }  
    return res;   
}  
  http://www.androidsnippets.org/snippets/70/

 

分享到:
评论

相关推荐

    Android 获取手机所有已安装的应用,并可以打开它

    List&lt;ApplicationInfo&gt; installedApps = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); for (ApplicationInfo app : installedApps) { if (!(app.flags & ApplicationInfo.FLAG_SYSTEM...

    apktool documentation

    W: Could not decode attr value, using undecoded value instead: ns=android, name=icon Can't find framework resources for package of id: 2. You must install proper framework files, see project website ...

    BURNINTEST--硬件检测工具

    Use a version of BurnInTest prior to 5.2 for compatibility with W98 and ME. Windows 95 and Windows NT ========================= Windows 95 and NT are not supported in BurnInTest version 4.0 and above...

    java实现获取安卓设备里已安装的软件包

    接下来,我们可以调用`getInstalledApplications(int flags)`方法来获取所有已安装的应用程序信息。这个方法返回一个`ApplicationInfo`对象的列表,其中包含了每个应用的基本信息。在这里,我们传入`PackageManager....

    EurekaLog_7.5.0.0_Enterprise

    34)..Changed: EurekaLog 7 now can be installed over EurekaLog 6 automatically, with no additional actions/tools EurekaLog 7.4 (7.4.0.0), 26-January-2016 1)....Fixed: Performance issue in DLL exports...

Global site tag (gtag.js) - Google Analytics