0

In Android development, we have Parcelable interface. Since I wish to build Data Models that will run on multiple apps and services (not just Android), I would like to add two jar libs that will share some of the code across multiple implementations: 1. The first A is coupled with Android SDK 2. The second B is not coupled with Android SDK

The B package will contain Data Models (POCO objects), for example. Since B has no reference to Android SDK, and I would like my POCO objects to implement Parcelable, then I think it would be nice to inherit from all POCO objects and implement the Parcel objects only in package A.

The same goes for methods and utilities that are only available in Android, and have other implementations in Java.

Is that the right approach for developing multiple apps and services that might share code?

  • "Is that the right approach" - Right in what sense? If it works and you can share code, then that's not bad... – Trilarion May 26 '16 at 11:33
0

So, it does seems to be the approach in the eyes of DevOps. Code sample: This is a class from package B (as defined in the question):

public class APIResponseStatus implements Serializable {  
  protected String errorCode = null;
  protected String status = null;
  protected String message = null;
  ....
}

This is a class from package A (as defined in the question):

public class APIResponse extends APIResponseStatus implements Parcelable {  
  .... // including Parcelable implementation
}

This line of code works as expected:

APIResponse response = intent.getParcelableExtra("RESPONSE_OBJECT");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.