i’ve a receiver that is fired on any application uninstall. I want to get the UID of the application . Currently i got the package name that was uninstalled but when i’m trying to get the UID, its returning null. Currently, i’m getting the UID of any package from 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;
}
You can’t get the UID after the package has been uninstalled because it is no longer there. The broadcast
Intentis sent after the package has been removed. However……from the documentation:
The broadcast
Intentthat is broadcast when the application is removed (uninstalled) contains an extraEXTRA_UIDcontaining the integer uid previously assigned to the package.