Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android package replace intent

Tags:

android

In my application I am listening for following 3 intents by using broadcast receiver.

ACTION_PACKAGE_REPLACED
ACTION_PACKAGE_REMOVED
ACTION_PACKAGE_ADDED

The problem is that whenever I reinstall some application First I get ACTION_PACKAGE_REMOVED then I get ACTION_PACKAGE_ADDED then I get ACTION_PACKAGE_REPLACED.

Is there any way to know that in reinstallation of application the ACTION_PACKAGE_REMOVED and ACTION_PACKAGE_ADDED intents belongs to ACTION_PACKAGE_REPLACED. I mean these are not the intents when only application is removed and installed respectively.

Thx Dalvin

like image 499
Dalvinder Singh Avatar asked Mar 04 '26 14:03

Dalvinder Singh


1 Answers

This may be too late, but I was looking for something similar and came across the extra EXTRA_REPLACING which will be present in the intent ACTION_PACKAGE_REMOVED if it will be immediately followed by an Add.

I figured this extra could be used to differentiate between actual replacement and only additions/removals. And sure enough, I came across this post on SO which does the exact same thing.

like image 94
curioustechizen Avatar answered Mar 06 '26 05:03

curioustechizen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!