문제

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 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top