There is only one way.
1 Public synchronized Staticdrawable geticonfrompackagename (String PackageName, Context context) {2Packagemanager pm =Context.getpackagemanager ();3 if(Build.VERSION.SDK_INT >=Build.version_codes. ICE_CREAM_SANDWICH_MR1) {4 Try {5PackageInfo pi = pm.getpackageinfo (packagename, 0);6Context Otherappctx =Context.createpackagecontext (PackageName, context.context_ignore_security);7 intDisplaymetrics[] ={Displaymetrics.density_xxxhigh,displaymetrics.density_xxhigh,displaymetrics.density_xhigh, Displaymetrics.density_high, DISPLAYMETRICS.DENSITY_TV};8 for(intdisplaymetric:displaymetrics) {9 Try {Tendrawable d =otherappctx.getresources (). Getdrawablefordensity (Pi.applicationInfo.icon, displaymetric); One if(d! =NULL) { A returnD; - } -}Catch(resources.notfoundexception e) { the Continue; - } - } -}Catch(Exception e) { + //Handle Error here - } + } AApplicationInfo AppInfo =NULL; at Try { -AppInfo = Pm.getapplicationinfo (packagename, 0); -}Catch(packagemanager.namenotfoundexception e) { - return NULL; - } - returnAppinfo.loadicon (PM); in}
android--get high-definition app icon