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

后端 未结 4 1731
忘了有多久
忘了有多久 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 03:56

    Try this:

    try
    {
        Drawable icon = getContext().getPackageManager().getApplicationIcon("com.example.testnotification");
        imageView.setImageDrawable(icon);
    }
    catch (PackageManager.NameNotFoundException e)
    {
        e.printStackTrace();
    }
    

提交回复
热议问题