當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。