Throw exception when trying to get icon from package name

301 Views Asked by At

I am trying to get an icon from a package name. The package name is getting passed to me through a socket. I am getting the package name and trying to use it to get the icon, but it is throwing an exception. I never get the print statement for the icon. Any ideas why?

           try  {

              Socket socket = new Socket("192.170.10.15", 5050);


              DataInputStream DIS = new DataInputStream(socket.getInputStream());


              String packagename = DIS.readUTF();
              System.out.println("package name" + packagename);


              Drawable icon = getPackageManager().getApplicationIcon(packagename);
              System.out.println("icon" + icon);


              socket.close();


           } catch (Exception e) {
              System.out.println("Did not receive string");
           }

The exception that is getting thrown is this: my exception now, when I want the icon for "Iso Mounter" app, is:

Exception is android.content.pm.PackageManager$NameNotFoundException: com.iso.mounter –
0

There are 0 best solutions below