开发者

Convert a Bitmap into a resource id

开发者 https://www.devze.com 2023-04-11 07:32 出处:网络
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, b

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号