我在 Manifest 中注册了一个全局的 Broadcast Receiver,它会在用户卸载包时显示一个通知。
<receiver android:name=".YourReceiver">
<intent-filter android:priority="999">
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="com.times.REFRESH_INSTALL_FLAG" />
<data android:scheme="package" />
</intent-filter>
</receiver>
问题是当某些包从 Play Store 更新时 android.intent.action.PACKAGE_REMOVED 和 android.intent.action.PACKAGE_ADDED 相继调用。
问题是我无法区分软件包是卸载还是更新。
一种方法是等到我们收到相同包名的PACKAGE_ADDED,然后关闭通知。
还有其他正确的方法可以实现吗?
最佳答案
我自己搞定了!通过查看收到的包名是否安装来区分!
关于android - 在包更新时防止 android.intent.action.PACKAGE_REMOVED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41972981/