android - Android - 当应用程序在 Google Playstore 中自动更新时如何在应用程序中获取回调
问题描述
每次更新应用程序时,我都需要清除缓存并注销用户,以便用户从后端获取最新数据。我已经实现了支持应用内更新,但由于一些 Playstore 缓存,它不适用于每个用户。我尝试使用以下代码注册我的广播接收器:
<receiver android:name=".YourReceiver">
<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>
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addAction(Intent.ACTION_PACKAGE_INSTALL);
intentFilter.addDataScheme("package");
registerReceiver(br, intentFilter);
但它没有工作,它没有捕获应用程序更新事件或删除事件。
在以下情况下,当我的应用程序从 Playstore 自动更新时,如何捕获应用程序更新事件?
- 应用自动更新时用户没有打开应用
- 当应用程序自动更新时,用户已打开应用程序
解决方案
推荐阅读
- kotlin - Kotlin 根据 id 从其他两个创建新对象
- pyarrow - 是否可以根据时间边界而不是记录数在 Apache Arrow 中定义记录批次?
- r - 将 geom_line 和 geom_point 与 ggplotly 一起使用时出现奇怪的图例和工具提示文本
- rest - 如果通过rest api发布资源,是否必须存储资源?
- javascript - 如何将img向右对齐
- docker - 如何查看 Docker 容器基目录中的点文件(隐藏文件)
- python - GeoJson 文件在 Altair 中未正确绘制
- javascript - Node 14 ECMAScript 模块:导入没有文件扩展名的模块?
- vue.js - 如何使用 NuxtLink 并通过页面发送数据
- c# - 使用约束定义/引发通用事件