Task to remove application UID

I have a receiver that starts when any application is uninstalled. I want to get the application UID. Currently, I got the name of the package that was deleted, but when I try to get the UID, it returns null. I am currently getting the UID of any package from the following code.

public String getID(String pckg_name) { ApplicationInfo ai = null; String id = ""; try { ai = pm.getApplicationInfo(pckg_name, 0); id = "" + ai.uid; } catch (final NameNotFoundException e) { id = ""; } return id; } 
+4
source share
1 answer

You cannot get the UID after the package has been deleted because it is no longer there. Intent transmission is sent after the packet is removed. But...

... from the documentation :

The broadcast Intent , which is transmitted when the application is uninstalled (deleted), contains an additional EXTRA_UID containing the integer uid previously assigned to the package.

+4
source

Source: https://habr.com/ru/post/1440022/


All Articles