当前位置: 首页>>代码示例>>Java>>正文


Java PackageManager.getInstalledPackages方法代码示例

本文整理汇总了Java中android.content.pm.PackageManager.getInstalledPackages方法的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.getInstalledPackages方法的具体用法?Java PackageManager.getInstalledPackages怎么用?Java PackageManager.getInstalledPackages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.getInstalledPackages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstalledApp

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public ArrayList<HashMap<String, String>> getInstalledApp(boolean z) {
    try {
        PackageManager packageManager = this.context.getPackageManager();
        List<PackageInfo> installedPackages = packageManager.getInstalledPackages(0);
        ArrayList<HashMap<String, String>> arrayList = new ArrayList();
        for (PackageInfo packageInfo : installedPackages) {
            if (z || !isSystemApp(packageInfo)) {
                HashMap hashMap = new HashMap();
                hashMap.put("pkg", packageInfo.packageName);
                hashMap.put("name", packageInfo.applicationInfo.loadLabel(packageManager)
                        .toString());
                hashMap.put("version", packageInfo.versionName);
                arrayList.add(hashMap);
            }
        }
        return arrayList;
    } catch (Throwable th) {
        Ln.w(th);
        return new ArrayList();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:DeviceHelper.java

示例2: isAvailable

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/** 检查手机上是否安装了指定的软件 */
public static boolean isAvailable(Context context, String packageName) {
    // 获取packagemanager
    final PackageManager packageManager = context.getPackageManager();
    // 获取所有已安装程序的包信息
    List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
    // 用于存储所有已安装程序的包名
    List<String> packageNames = new ArrayList<>();
    // 从pinfo中将包名字逐一取出,压入pName list中
    if (packageInfos != null) {
        for (int i = 0; i < packageInfos.size(); i++) {
            String packName = packageInfos.get(i).packageName;
            packageNames.add(packName);
        }
    }
    // 判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE
    return packageNames.contains(packageName);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ApkUtils.java

示例3: getComponentInfo

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private static List<PackageInfo> getComponentInfo(Context context,
		List<String> maps) {
	PackageManager pm = context.getPackageManager();
	List<PackageInfo> infos = pm.getInstalledPackages(0);
	List<PackageInfo> available = new ArrayList<PackageInfo>();
	if ((infos != null) && (infos.size() > 0))
		for (PackageInfo info : infos) {
			String packName = info.packageName;
			if (!TextUtils.isEmpty(packName) && maps.contains(packName)) {
				if (packName.equals(Autonavi_Map)) {
					if (info.versionCode >= 161)
						available.add(info);
				} else {
					available.add(info);
				}
			}
		}
	return available;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:20,代码来源:MapHelper.java

示例4: isInstalled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
public boolean isInstalled(Context context) {
    if(context == null)
        return false;

    final PackageManager packageManager = context.getPackageManager();
    List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
    if (pinfo != null) {
        for (int i = 0; i < pinfo.size(); i++) {
            String pn = pinfo.get(i).packageName;
            if (pn.equals("com.tencent.mobileqq")) {
                return true;

            } else if(pn.equals("com.tencent.qzone")) {
                return true;

            }
        }
    }
    return false;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:22,代码来源:ShareQQ.java

示例5: hasQQClientAvailable

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 判断 用户是否安装QQ客户端
 */
public static boolean hasQQClientAvailable(Context context) {
    final PackageManager packageManager = context.getPackageManager();
    List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
    if (pinfo != null) {
        for (int i = 0; i < pinfo.size(); i++) {
            String pn = pinfo.get(i).packageName;
            LogUtils.e("pn = " + pn);
            if (pn.equalsIgnoreCase("com.tencent.qqlite") || pn.equalsIgnoreCase("com.tencent.mobileqq")) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:paterWang,项目名称:EasyReader,代码行数:18,代码来源:FeedbackActivity.java

示例6: getPackages

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private static List<PackageInfo> getPackages(Context context) {
    if (cachePackageInfo == null) {
        PackageManager pm = context.getPackageManager();
        cachePackageInfo = pm.getInstalledPackages(0);
    }
    return new ArrayList<>(cachePackageInfo);
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:8,代码来源:Rule.java

示例7: getAllAppsInfo

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 获取所有已安装App信息
 * <p>{@link #getBean(PackageManager, PackageInfo)}(名称,图标,包名,包路径,版本号,版本Code,是否安装在SD卡,是否是用户程序)</p>
 * <p>依赖上面的getBean方法</p>
 *
 * @param context 上下文
 * @return 所有已安装的AppInfo列表
 */
public static List<AppInfo> getAllAppsInfo(Context context) {
    List<AppInfo> list = new ArrayList<>();
    PackageManager pm = context.getPackageManager();
    // 获取系统中安装的所有软件信息
    List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
    for (PackageInfo pi : installedPackages) {
        if (pi != null) {
            list.add(getBean(pm, pi));
        }
    }
    return list;
}
 
开发者ID:ChunweiDu,项目名称:Utils,代码行数:21,代码来源:AppUtil.java

示例8: getPackageNames

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
protected Set<String> getPackageNames(PreventActivity activity) {
    Set<String> names = new HashSet<String>();
    PackageManager pm = activity.getPackageManager();
    for (PackageInfo pkgInfo : pm.getInstalledPackages(0)) {
        ApplicationInfo appInfo = pkgInfo.applicationInfo;
        if (PackageUtils.canPrevent(pm, appInfo)) {
            names.add(appInfo.packageName);
        }
    }
    return names;
}
 
开发者ID:brevent,项目名称:prevent,代码行数:13,代码来源:Applications.java

示例9: isAppInstalled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static boolean isAppInstalled(Context context, String packageName) {
    final PackageManager packageManager = context.getPackageManager();
    List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
    List<String> pName = new ArrayList<String>();
    if (pinfo != null) {
        for (int i = 0; i < pinfo.size(); i++) {
            String pn = pinfo.get(i).packageName;
            pName.add(pn);
        }
    }
    return pName.contains(packageName);
}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:13,代码来源:InstallAPK.java

示例10: getAppsInfo

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 获取所有已安装App信息
 * <p>{@link #getBean(PackageManager, PackageInfo)}(名称,图标,包名,包路径,版本号,版本Code,是否系统应用)</p>
 * <p>依赖上面的getBean方法</p>
 *
 * @return 所有已安装的AppInfo列表
 */
public static List<AppInfo> getAppsInfo() {
    List<AppInfo> list = new ArrayList<>();
    PackageManager pm = Utils.getContext().getPackageManager();
    // 获取系统中安装的所有软件信息
    List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
    for (PackageInfo pi : installedPackages) {
        AppInfo ai = getBean(pm, pi);
        if (ai == null) continue;
        list.add(ai);
    }
    return list;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:20,代码来源:AppUtils.java

示例11: isApplicationInstalled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
boolean isApplicationInstalled(Context context, String packageName) {
    PackageManager packageManager = context.getPackageManager();
    List<PackageInfo> list = packageManager.getInstalledPackages(0);
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).packageName.equalsIgnoreCase(packageName)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:czy1121,项目名称:sdk3rd,代码行数:11,代码来源:SendShare.java

示例12: isInstalled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Checks if the app has been installed on the system.
 * @param packageManager PackageManager to use.
 * @param packageName Name of the package to check.
 * @return True if the PackageManager reports that the app is installed, false otherwise.
 */
public static boolean isInstalled(PackageManager packageManager, String packageName) {
    List<PackageInfo> packs = packageManager.getInstalledPackages(0);
    for (int i = 0; i < packs.size(); i++) {
        if (TextUtils.equals(packs.get(i).packageName, packageName)) return true;
    }
    return false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:InstallerDelegate.java

示例13:

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private boolean Ɨ(Context context, String packageName)
  {
final PackageManager packageManager = context.getPackageManager();
      List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
for (int i = 0; i < pinfo.size(); i++)
{
          if (pinfo.get(i).packageName.equalsIgnoreCase(packageName))
		return true;
}
return false;
  }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:12,代码来源:smali_layout_apktool_Util.java

示例14: getAppList

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static List<AppInfo> getAppList(Context context) {

        List<AppInfo> list = new ArrayList<AppInfo>();// 声明并实例化1个集合
        PackageManager pm = context.getPackageManager();//获取包管理者
        List<PackageInfo> pList = pm.getInstalledPackages(0);// 获取所有的应用程序集合
        // 循环遍历
        for (int i = 0; i < pList.size(); i++) {
            PackageInfo packageInfo = pList.get(i);// 获取每一个应用的信息

            if (isThirdPartyApp(packageInfo.applicationInfo)
                    // 不能包含本应用(不删除自己)
                    && !packageInfo.packageName.equals(context.getPackageName())) {

                // 从右边装到左边
                AppInfo appInfo = new AppInfo();
                appInfo.packageName = packageInfo.packageName;
                appInfo.versionName = packageInfo.versionName;
                appInfo.versionCode = packageInfo.versionCode;
                appInfo.firstInstallTime = packageInfo.firstInstallTime;
                appInfo.lastUpdateTime = packageInfo.lastUpdateTime;
                // 程序名称
                appInfo.appName = ((String) packageInfo.applicationInfo.loadLabel(pm)).trim();
                // 过渡
                appInfo.applicationInfo = packageInfo.applicationInfo;
                // 这行代码在运行时解除注释
                //appInfo.icon = packageInfo.applicationInfo.loadIcon(pm);
                // 计算应用的空间
                //publicSourceDir 是app的安装路径(文件夹)
                String dir = packageInfo.applicationInfo.publicSourceDir;
                long byteSize = new File(dir).length();
                appInfo.byteSize = byteSize;// 1024*1024 Byte字节
                appInfo.size = getSize(byteSize);// 1MB

                list.add(appInfo);// 添加到集合
            }// if

        }

        return list;
    }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:41,代码来源:apitils.java

示例15: getAllApp

import android.content.pm.PackageManager; //导入方法依赖的package包/类
String getAllApp(boolean isOnlyGetPackageName)
{
	String ret = "";
	PackageManager pm = getPackageManager();
	List<PackageInfo> ls = pm.getInstalledPackages(0);
	for (int i=0;i < ls.size();i++)
	{
		PackageInfo pi=ls.get(i);
		if (!isOnlyGetPackageName)
		{
			if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0)	
			{
				ret += "一般应用\n";
			}
			else
			{
				ret += "系统应用\n";
			}
		}
		if (!isOnlyGetPackageName)
		{
			ret += pi.applicationInfo.loadLabel(pm).toString() + "\n" + pi.packageName + "\n\n";
		}
		else
		{
			ret += pi.packageName + "\n";
		}
	}
	return ret;
}
 
开发者ID:nijigenirubasho,项目名称:mobiletailchanger,代码行数:31,代码来源:XposedCfgActivity.java


注:本文中的android.content.pm.PackageManager.getInstalledPackages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。