【问题标题】:Intent to get the UID of application uninstalled意图获取卸载应用程序的 UID
【发布时间】:2012-10-16 10:46:56
【问题描述】:

我有一个在任何应用程序卸载时都会触发的接收器。我想获取应用程序的 UID。目前我得到了已卸载的包名称,但是当我尝试获取 UID 时,它返回 null。目前,我正在从以下代码中获取任何包的 UID。

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;
    }

【问题讨论】:

    标签: android android-intent uid


    【解决方案1】:

    卸载软件包后,您将无法获取 UID,因为它不再存在。广播Intent 是在 包被删除之后发送的。不过……

    ...来自documentation

    在删除(卸载)应用程序时广播的广播Intent 包含一个额外的EXTRA_UID,其中包含先前分配给包的整数uid。

    【讨论】:

    • 实现了同样的!!正要回答我的问题:)
    猜你喜欢
    • 2011-10-10
    • 2011-12-13
    • 1970-01-01
    • 2015-04-28
    • 2011-02-21
    • 2013-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多