I want to raise a notification showing an icon in the status bar - so far so good, but actually I would like this icon to be a 3 character String.
So my question is: Is there a way to convert my String into a Drawable
to display it as Icon in the status bar?
EDIT: I recently found an app which does something similar - Battery Indicator
It shows the current battery level as notification icon in the status bar - I wonder if it really uses different 100 images
(I know this doesn't answer the OP's question fully, but the title got me here since it's pretty general.)
After fiddling around a bit, I've come up with this solution. It's pretty messy and could probably be improved, but it works.
In its current form, the function takes the first letter of the String it's passed and a unique ID for that String. The ID is only used for background color generation and remembering it, so it can be removed if you're going to use a steady color.
I made this to generate default images for contacts that don't have images saved, but it should be easy to adapt. It also happens to return an InputStream instead of a Drawable, but you can either just return
bitmap
after drawing to it, or useDrawable.createFromStream()
.