The Android project in question already uses Serializable to pass information between internal modules.
I am working on one of those Modules which also uses External Libraries to calculate Navigation Routes.
I need to pass one of those "external" objects to another module, this is not Serializable so I am not able to send it normally. The programmer before me had transformed all non serializable Objects in static variables in a Wrapper Class, I am not sure if that is a good idea even though the modules should remain active the whole time.
This is the Serializable wrapper class:
private static Road road;
private NavigationStep firstNavigationStep;
/**
* To send the route information to the App. Here is everything the app needs to display the
* data to the user.
* @param road the route the user is to follow
* @param firstNavigationStep the users location and the current Step.
*/
public CurrentRoad(Road road, NavigationStep firstNavigationStep){
this.firstNavigationStep = firstNavigationStep;
this.road = road;
}
Writing the Road as transient makes me lose data, writing a whole wrapper class for road would be too much work(it is needed to build overlays, so a lot of Geometry is inside and is from an external library so I may forget something). Changing the whole Project to Parcelable is also not realistic.
Is there any solution? Is the best way really to just save what I need as static?
Try using EventBus. Send Sticky event, containing object reference. It will be delivered to every subscribed object until you explicitly cancel that event.