Between android roms the contacts app's logo can be different (e.g. Samsung devices have different contacts icon than HTC devices). Is there any way to programmatically get this icon?
Asked
Active
Viewed 250 times
3
-
Maybe [this question](http://stackoverflow.com/q/4600740/1343161) can help? – Keppil Oct 23 '12 at 13:40
1 Answers
2
private Drawable getIconFromPackageName(final String packageName) {
PackageManager packageManager = getPackageManager();
try {
Drawable icon = packageManager.getApplicationIcon(packageName);
return icon;
} catch (NameNotFoundException e) {
Toast toast = Toast.makeText(this, "error in getting icon", Toast.LENGTH_SHORT);
toast.show();
e.printStackTrace();
}
return null;
}
This will return a Drawable
object with the specified package name's icon if it exists, null
otherwise.

Raghav Sood
- 81,899
- 22
- 187
- 195