如果我知道其包名称,如何从设备上的其他Android应用程序进入Icon Launcher?
实施例
String googlePackageName = "com.google.maps";
Drawable googleIcon = googlePackageName.getIconLauncher() or something.
答案 0 :(得分:19)
使用PackagerManager的getApplicationIcon()执行此任务:
Drawable appIcon = getPackageManager().getApplicationIcon("com.google.maps");
答案 1 :(得分:2)
我遇到了这个问题。从来没有听说过。 但我想这应该是解决方案:
Drawable icon = context.getPackageManager().getApplicationIcon(packageName);
答案 2 :(得分:1)
以下剪辑应指向正确的方向:
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setPackage( packageName );
final List<ResolveInfo> pkgAppsList = pm.queryIntentActivities( intent, 0 );
if( pkgAppsList.size() > 0 ) {
this.url = pkgAppsList.get(0).activityInfo.name;
icon = pkgAppsList.get(0).activityInfo.loadIcon( pm );
this.displayName = pkgAppsList.get(0).activityInfo.loadLabel( pm ).toString();
this.module = pkgAppsList.get(0).activityInfo.packageName;
this.isExternal = true;
this.count = count;
}