I got frustrated too. My need was very straightforward. All I wanted was the ARGB color from the resources, so I wrote a simple static method.
protected static int getARGBColor(Context c, int resId)
throws Resources.NotFoundException {
TypedValue color = new TypedValue();
try {
c.getResources().getValue(resId, color, true);
}
catch (Resources.NotFoundException e) {
throw(new Resources.NotFoundException(
String.format("Failed to find color for resourse id 0x%08x",
resId)));
}
if (color.type != TYPE_INT_COLOR_ARGB8) {
throw(new Resources.NotFoundException(
String.format(
"Resourse id 0x%08x is of type 0x%02d. Expected TYPE_INT_COLOR_ARGB8",
resId, color.type))
);
}
return color.data;
}