ACTION_MY_PACKAGE_REPLACED not received

后端 未结 9 712
长发绾君心
长发绾君心 2020-12-08 00:59

I am using ACTION_MY_PACKAGE_REPLACED to receive when my app is updated or resinstalled. My problem is that the event is never triggered (I tried Eclipse and real device). T

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 01:27

    Are you trying it on a API>=12 device/emulator? This broadcast will not be sent on prior cases as it is API 12. If you need your app to receive this for Pre-ICS and the old honey comb devices,

    try:

    if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
      if (!intent.getData().getSchemeSpecificPart()
           .equals(context.getPackageName())) {
        return;
      }
    }
    

提交回复
热议问题