Frage

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;
    }
War es hilfreich?

Lösung

You can't get the UID after the package has been uninstalled because it is no longer there. The broadcast Intent is sent after the package has been removed. However...

...from the documentation:

The broadcast Intent that is broadcast when the application is removed (uninstalled) contains an extra EXTRA_UID containing the integer uid previously assigned to the package.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top