我通过以下代码存储了应用程序的包名称。
mActivityManager = (ActivityManager)this.context.getSystemService(Context.ACTIVITY_SERVICE);
for (ApplicationInfo packageInfo : packages)
{
String pck = packageInfo.packageName;
if(pck.startsWith("com.google") )
{
app = new APP(R.drawable.ic_launcher,packageInfo.packageName);
application_package.add(app);
continue;
}
if((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM)==1)continue;
if(packageInfo.packageName.equals("com.walton.taskkiller")) continue;
app = new APP(R.drawable.ic_launcher,packageInfo.packageName);
application_package.add(app);
}
现在我想知道应用程序名称和应用程序图标。如何从应用程序包中获取应用程序名称和应用程序图标?
答案 0 :(得分:2)
首先获取包管理器的实例:
PackageManager packageManager = getPackageManager();
现在通过ApplicationInfo实例获取App name和App图标:
String appName = applicationInfo.loadLabel(packageManager)
Drawable appIcon = applicationInfo.loadIcon(packageManager)