How can i get the application's icon from the package name?

后端 未结 4 1704
忘了有多久
忘了有多久 2020-12-01 03:26

I have tried various solution from stack overflow with no luck. What I want.

  1. I know package name of different applications.
  2. I want to get application
4条回答
  •  有刺的猬
    2020-12-01 04:06

    try
    {
        Drawable drawable = getPackageManager()
                .getApplicationIcon("com.whatsapp");
        imageView.setImageDrawable(drawable);
    }
    catch (PackageManager.NameNotFoundException e)
    {
        e.printStackTrace();
    }
    

提交回复
热议问题