代码
1 final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
2 mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
3 final List<ResolveInfo> pkgAppsList = this.getPackageManager().queryIntentActivities( mainIntent, 0);
4 for(int i = 0; i < pkgAppsList.size(); i++){
5 ResolveInfo info = pkgAppsList.get(i);
6 Drawable drawable = info.loadIcon(getPackageManager());
7 ImageView image = new ImageView(this);
8 image.setBackgroundDrawable(drawable);
9 image.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
10 layout.addView(image);
11 Log.v("dfadf", "dfasdf");
12 }