Creating a shortcut: how can I work with a drawable as Icon?

前端 未结 2 1653
半阙折子戏
半阙折子戏 2021-02-06 10:54

Below is My code to create a shortcut to a selected application. I have really no problem and the application work quite well.

The problem is that I am able to create a

2条回答
  •  旧巷少年郎
    2021-02-06 11:02

    Finally found a solution; I was stupid to use Intent.EXTRA_SHORTCUT_ICON_RESOURCE:

    Here is the correct code:

    Drawable iconDrawable = (....); 
    BitmapDrawable bd = (BitmapDrawable) iconDrawable;
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bd.getBitmap());
    

提交回复
热议问题