My application shows some notifications, and depending on user preferences it might use a custom layout in a notification. It works well, but there is a small problem — text colors. Stock Android and almost all manufacturer skins use black text against a light background for notification text, but Samsung doesn’t: their notification pulldown has a dark background and the text in the default notification layout is white.
So this causes a problem: the notifications that don’t use any fancy layouts show up fine, but the one that uses a custom layout is hard to read because the text is black instead of the default white. Even the official documentation just sets a #000 color for a TextView, so I couldn’t find any pointers there.
A user was kind enough to take a screenshot of the problem:

So how do I use the default notification text color from the device in my layouts? I’d rather not start dynamically altering the text color based on phone model, since that requires a lot of updating and people with custom ROM’s might still get the problem, depending on the skin they’re using.
Solution by Malcolm works fine with API>=9. Here’s the solution for older API:
The trick is to create the standard notification object and then traverse the default
contentViewcreated byNotification.setLatestEventInfo(...). When you find the right TextView, just get thetv.getTextColors().getDefaultColor().Here’s the code that extracts the default text color and text size (in scaled density pixels – sp).
Call
extractColorsie. in onCreate() of your service. Then when you’re creating the custom notification, the color and text size you want are innotification_text_colorandnotification_text_size: