如何从谷歌Play商店Android中安装应用程序的列表? [英] How to get the list of installed application from google play store in android?

查看:189
本文介绍了如何从谷歌Play商店Android中安装应用程序的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,从谷歌Play或任何外部存储安装的应用程序列表中,但不是pre安装的系统应用。

i want the application list that is installed from google play or from any external storage, but not the pre installed system application.

我只是使用下面code .....

i just use below code.....

 class PInfo {
    private String appname = "";
    private String pname = "";
    private String versionName = "";
    private int versionCode = 0;
    private Drawable icon;
    private void prettyPrint() {
        Log.v("", "*** appname = " + appname + " *** \n" + " packagename = " + pname + "\n" + " version name =  " + versionName + "\n" + " version code = " + versionCode + " \n\n\n\n");
    }
}

private ArrayList<PInfo> getPackages() {
    ArrayList<PInfo> apps = getInstalledApps(true); /* false = no system packages */
    final int max = apps.size();
    int i = 0; 
    for (i=0; i<max; i++) {
        apps.get(i).prettyPrint();
    }
    Log.v(TAG, "Total APPs = "+i);
    return apps;
}

private ArrayList<PInfo> getInstalledApps(boolean getSysPackages) {
    ArrayList<PInfo> res = new ArrayList<PInfo>();        
    List<PackageInfo> packs = getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA);
    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; 
}

但这种code给我系统的应用也......

but this code gives me information of system application also.....

能有人知道如何得到的只是安装的应用程序,除了已安装的系统应用?

can anybody know how to get only installed application except the installed system application ?

感谢....

推荐答案

要发现,如果你的应用程序,你可以使用下面的code系统应用程序:

To discover if your application is a system application you can use the following code:

PackageManager pm = getPackageManager();
List<ApplicationInfo> installedApps = pm.getInstalledApplications(0);

for (ApplicationInfo aInfo: installedApps) {

    if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        // system application
    } else {
        //user application
    }
}

如果您需要如果一个应用程序从市场安装到发现你需要使用下封装方法: getInstallerPackageName 。这将返回安装了应用程序的应用程序中的packageName。

If you need to discover if an application is installed from a market you need to use the following method of Package: getInstallerPackageName. It will return the packageName of the application that installed your application.

这篇关于如何从谷歌Play商店Android中安装应用程序的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆