Convert a Bitmap into a resource id
I have a Bitmap
, and I'd like a resource id (like R.drawable.whatever
) for it instead to pass to Notification (I'm stuck at api level 8 for compatibility reasons). Is this possible? I suspect not, but I want to make sure bef开发者_运维知识库ore I give up.
No, it is not possible. Sorry :P
Ressource ids are generated at apk build time and totally immutable.
Bottom line : if your Bitmap has to be pulled from somewhere later, you're stuck. Corrolary: No notification icon are younger than their apk (up to gingerbread).
perhaps you can use this code :
Drawable d = new BitmapDrawable(getResources(),bitmap);
reference : http://www.vogella.com/articles/AndroidDrawables/article.html
精彩评论