Demo entry 6745362

java

   

Submitted by anonymous on May 27, 2018 at 02:45
Language: Java. Code size: 821 Bytes.

	public void initCacheInfos()
	{
		// 获取到所有安装了的应用程序的信息,包括那些卸载了的,但没有清除数据的应用程序
		List<PackageInfo> packageInfos = packageManager
				.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
		size = packageInfos.size();
		for (int i = 0; i < size; i++)
		{
			PackageInfo packageInfo = packageInfos.get(i);
			CacheInfo cacheInfo = new CacheInfo();
			// 拿到包名
			String packageName = packageInfo.packageName;
			cacheInfo.setPackageName(packageName);
			// 拿到应用程序的信息
			ApplicationInfo applicationInfo = packageInfo.applicationInfo;
			// 拿到应用程序的程序名
			String name = applicationInfo.loadLabel(packageManager).toString();
			cacheInfo.setName(name);
			// 拿到应用程序的图标
			Drawable icon = applicationInfo.loadIcon(packageManager);
			cacheInfo.setIcon(icon);

			initDataSize(cacheInfo, i);
		}
	}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).