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 自动更新时,如何捕获应用更新事件?

  1. 当应用自动更新时,用户没有打开应用
  2. 当应用自动更新时,用户已打开应用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...