2

I'm using NotificationListenerService for catching notification, with the help of kpbird blog. But I'm unable to extract the icon's drawable. I'm also going through this, but things are not cleared to me. Please help.

Community
  • 1
  • 1
PPB
  • 151
  • 1
  • 14

1 Answers1

3

To get other application icon, just get package name of that application and use below code. You will get package name from notification instance.

String pack= "com.whatsapp" // ex. for whatsapp;
        Context remotePackageContext = null; 
        Bitmap bmp = null;
        try {  
            remotePackageContext = getApplicationContext().createPackageContext(pack, 0);  
            Drawable icon = remotePackageContext.getResources().getDrawable(id);  
            if(icon !=null) {  
                bmp = ((BitmapDrawable) icon).getBitmap();
            }

        } catch (Exception e) {  
            e.printStackTrace();  
        }