Android app update broadcast

前端 未结 3 1631
暗喜
暗喜 2020-12-18 02:30

So, im working on something that requires me to know when another application on the device is being updated. So my question is quite simple, does lets say YouTube or Spotif

3条回答
  •  感情败类
    2020-12-18 03:11

    ACTION_PACKAGE_REPLACED is action triggered when an application is being updated According to docs :

    A new version of an application package has been installed, replacing an existing version that was previously installed. The data contains the name of the package.

    intent.getPackage() returns the package/application this intent was specifically addressed to but it was sent to any interested receiver, therefore, there isn't such package.

    Use intent.getData() which returns the updated package as an Uri

    Add the below intent filter while registering a broadcast receiver in your Manifest.xml

    
       
       
    
    

提交回复
热议问题