3

I have a Parcelable structure which I send within Intent via Context.sendBroadcast() to be processed with some application's receiver further.

In update version of my application I change the Parcelable's structure so I change types of some fields.

I would like to know if the sending broadcast is called just before application update will it be preserved somewhere in the system with the old Parcelables structure so I have a chance to get it further in my application with some following exception caused by inability to read Parcelable because of not relevant structure?

Or I'm wrong and Android handles such situations in some different manner?

Alex Bonel
  • 1,344
  • 1
  • 9
  • 22

1 Answers1

0

As the doc says, it is not recommended to send parcelable between processes.

For example, an app might set an alarm using the AlarmManager class, and use a custom Parcelable on the alarm intent. When the alarm goes off, the system modifies the intent's Bundle of extras to add a repeat count. This modification can result in the system's stripping the custom Parcelable from the extras. This stripping, in turn, can result in the app's crashing when it receives the modified alarm intent, because the app expects to receive extra data that is no longer there.

https://developer.android.com/guide/components/activities/parcelables-and-bundles

So, it is better to save only a String ID to your object. And you can load it from somewhere else, like a local database.

dimrsilva
  • 141
  • 1
  • 4
  • Actually, the AlarmManager remove all alarms after app update. So you have to save new alarms. https://stackoverflow.com/questions/49704914/alarmmanager-when-app-is-updated – dimrsilva Jun 07 '19 at 18:22