Retrieving xhdpi app icons from packageManager?

前端 未结 3 553
终归单人心
终归单人心 2020-12-10 19:58

I have an activity in my app wherein a ListView of all installed apps is generated. In addition to the app name, the app icon appears as well. I had created an array of obje

3条回答
  •  一向
    一向 (楼主)
    2020-12-10 20:13

    ApplicationInfo applicationInfo = 
            packagemanager.getApplicationInfo(packageName(), PackageManager.GET_META_DATA);
    Resources res = packagemanager.getResourcesForApplication(applicationInfo);
    Drawable appIcon = res.getDrawableForDensity(applicationInfo.icon, 
                                                 DisplayMetrics.DENSITY_XXXHIGH, 
                                                 null);
    

提交回复
热议问题