Question

Let's say I have the following class structure

public class SipService implements Parcelable{

public SipCore sipcore;
public PhoneRinger phoneringer;
public CurrentML currentml;
public AManager amanager;
//etc...
}

All the properties of SipService are non-parcelable classes. And the properties of those properties are non-parcelable classes. And the properties of those properties of those properties are non-parcelable classes. And the properties of those properties etc.... are non-parcelable classes.

I do not have access the to the source code for any of those classes of the properties of SipService.

Does this mean that SipService can not successfully implement Parcelable?

Was it helpful?

Solution

Because you don't have access to all the member variables of the classes and can't change this, you can't make SipService parcelable.

If you would have access, you could read all the variables of the classes in your SipService and make a new instance of them. But for that you need the getters and a appropriate constructor for each class to rebuild them.

If these classes are implementing the Serializable interface, you could make it serializable. Because it's behaving pretty much the same, but the performance is better if the class implements parcelable.

OR

If you can talk to the team, suggest them to implement the parcelable/serializable interface if it's a reasonable requirement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top