开发者

How to show other applications icons on a widget?

I'm trying to show some applications' icons on an Android widget.

I can get the icon as a drawable with:

Drawable d = context.getPackageManager().getApplicationIcon(appInfo);

but then I need to update the widget with the icon, and RemoteViews only accept Bitmap.

Anyway to convert a Drawable to a Bitmap?

I've tried this but it didn't work

            Bitmap bitmap = Bitmap.createBitmap(64, 
                    64, Config.RGB_565);

            Canvas c = new Canvas(bitmap);              

            d.draw(c);

I know it's possible since 开发者_Python百科I've seen apps in the market that do it.

Thanks.


found it: remoteViews.setImageViewBitmap(R.id.icon1, ((BitmapDrawable)d).getBitmap());

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜