I have tried various solution from stack overflow with no luck. What I want.
if you want to get icon (picture) of any installed application from there packagename, then just copy and paste this code. it will work
try
{
Drawable d = getPackageManager().getApplicationIcon("com.AdhamiPiranJhandukhel.com");
my_imageView.setBackgroundDrawable(d);
}
catch (PackageManager.NameNotFoundException e)
{
return;
}
Try this:
try
{
Drawable icon = getContext().getPackageManager().getApplicationIcon("com.example.testnotification");
imageView.setImageDrawable(icon);
}
catch (PackageManager.NameNotFoundException e)
{
e.printStackTrace();
}
This also works:
try
{
Drawable d = getPackageManager().getApplicationIcon(getApplicationInfo());
my_imageView.setBackgroundDrawable(d);
}
catch (PackageManager.NameNotFoundException e)
{
return;
}
try
{
Drawable drawable = getPackageManager()
.getApplicationIcon("com.whatsapp");
imageView.setImageDrawable(drawable);
}
catch (PackageManager.NameNotFoundException e)
{
e.printStackTrace();
}