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
Have you looked at the API Demos > App > Notifications > Status Bar?
If you have limited number of String options (like Smileys) you can create drawables for each of those Strings.
No you can not, I thought you could use the same method as here: Combine image and text to drawable, but you can't, as the notification takes a drawable id, not a drawable object.
Short: No, you can't.
Long: The notification needs a
R.drawable.something
for the icon and you can't create it on runtime.you can make your own custom drawable that would work just like the textview widget except it is a drawable instead of a view. The textview class is just a container for the drawable that contains the text.
I have used a workaround and it worked properly for me.
First i convert the string to bitmap and then convert it to a drawable, here is the code:
Hope it helps!