anon
anon

Reputation:

What happens to BroadcastReceiver when application is updated?

I am setting an alarm (launched every 10 minutes) using AlarmManager together with BroadcastReceiver in my application.

What exactly happens when the application is updated (either by updating through Google Play or by installing application with higher version code directly through ADB), will the receiver still work? Can I trigger some actions related to BroadcastReceiver when the application is updated?

Upvotes: 0

Views: 66

Answers (2)

Arnab Bhagabati
Arnab Bhagabati

Reputation: 2715

You use AlarmManager to create alarms. What makes you use BroadcastReceiver to create an alarm?

Is it that you have 2 applications and you are using BroadcastReceiver from app1 to launch the alarm[manager] from app2 ?

Otherwise, I believe your approach is wrong and BroadcastReceiver is renundant.

UPDATE
On the basis of your updated question, the crux of the question seems to be :

Will the BroadcastReceiver work if the applivcation is updated?
As long as you have the correct BroadcastReciever code in the updated verion of your app, it will.


Can I trigger some actions related to BroadcastReceiver when the application is updated?
You want to change your BroadcastReceiver/ remove your BroadCastreceiver -- you can.

Want some specific code to trigger on application being updated: use ACTION_PACKAGE_REPLACED as ben75 suggested

Upvotes: 1

ben75
ben75

Reputation: 28706

You can register a receiver for the action ACTION_PACKAGE_REPLACED to be notified when your app is updated.

But, in your particular use case : you probably setup the alarm when your app starts. After an application update: your app starts again and so the alarm will be setup correctly.

Upvotes: 2

Related Questions