android - 如何获取上次安装的应用程序的名称

标签 android android-intent broadcastreceiver

我写了一个广播接收器来检测这样的应用程序安装事件

  <receiver android:name="ApplicationBroadcastService" >
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_INSTALL" />
            <action android:name="android.intent.action.PACKAGE_ADDED" />
            <data android:scheme="package" />
        </intent-filter>
    </receiver>

现在,我想获取最后安装的应用程序的名称,我该怎么做,谢谢。

最佳答案

Intent 中的 Uri(通过 getData() 获取)将包含已安装应用程序的包名称。然后,您可以使用 PackageManager 获取有关给定包名称的应用的更多详细信息。

关于android - 如何获取上次安装的应用程序的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10445740/

相关文章:

Android - 如何为不同主题中的某些特定 View 指定特殊属性

android - Appium ERROR 转储失败,因为无法加载 Assets : Invalid file Support

android - MediaStore.Images.Media.insertImage 已弃用

android - 使用 SimpleCursorAdapter OnItemClickListener 的 ListView 不起作用

android - 分享图片的正确方式(使用 Intents)

android - 在广播接收器上获得不需要的多重 Intent

BroadcastReceiver的onReceive函数中的Android startActivity

android - Cordova APP - 是否可以在容器中显示相机提要?

java - 我正在使用自定义列表有两个按钮,一个表单和第二个用于 whatsapp

android - 如何检测 Android 4.2 中的 USB 连接?