I'm trying to get an icon of the installed app. Using the following way, I'm getting the error:
The method getContext() is undefined for the type MainActivity
try{
String pkg = "com.app.my";//your package name
Drawable icon = getContext().getPackageManager().getApplicationIcon(pkg);
imageView.setImageDrawable(icon);
}
catch (PackageManager.NameNotFoundException ne) {
}
It would be very helpful if someone could guide me. Thanks in advance!!