This can only be done in API 11+ if your background is solid color. Easy to get it like drawable
Drawable mIconBackground = mIcon.getBackground(); if (mIconBackground instanceof ColorDrawable) color = ((ColorDrawable) background).getColor();
And if you are on Android 3.0+, you can exit the color resource identifier.
int colorId = mIcon.getColor();
And compare this to the assigned colors, i.e.
if (colorId == Color.GREEN) { log("color is green"); }
Hope this helps you.
source share