Here is the only thing I didn't get about AIDL and couldn't find anything on Google or Stackoverflow:
I have an activity and a service, each in different processes, and they tightly communicate via IPC using AIDL. One of the methods in AIDL communication interface needs to get list of my-custom-parcelable-class objects from service and return them to activity.
I'm confused with import statements in AIDL interface and on both ends in activity and service. In AIDL interface I import my .aidl parcelable declaration. Whereas if in activity and service I import my real (.java) parcelable class, and those declarations conflict, because AIDL interface implementation wants me to return .aidl parcelable but I return real parcelable.
I will try to make it more clear with code:
In my Service I'm sending list of MyParcelable:
import package-with-java-files.MyParcelable; // IMPORTING REAL MyParcelable
...
protected final InterprocessCommunicator.Stub binder = new InterprocessCommunicator.Stub() {
@Override
public List<MyParcelable> getMyParcelables() throws RemoteException { // CONFLICT
return MyService.this.getMyParcelables();
}
}
In my AIDL interface I declare method that returns the list:
package package-with-aidl-files;
import package-with-aidl-files.MyParcelable; // IMPORTING AIDL MyParcelable
interface InterprocessCommunicator {
List<MyParcelable> getMyParcelables();
}
In my AIDL parcelable declaration (this is what I call AIDL MyParcelable):
package package-with-aidl-files;
parcelable MyParcelable;
In my java parcelable declaration (this is what I call real MyParcelable):
package package-with-java-files;
public class MyParcelable implements Parcelable {
...
}
Finally in my Activity I'm receiving list of MyParcelable:
import package-with-java-files.MyParcelable; // IMPORTING REAL MyParcelable
...
void someMethod() {
List<MyParcelable> responses = interprocessCommunicator.getMyParcelables(); // CONFLICT
....
}
I hope now it's more clear where the conflicts are: in Service where I'm returning list of package-with-java-files.MyParcelable, but the AIDL interface expects package-with-aidl-files.MyParcelable and same thing in Activity
How to resolve those conflicts? I cannot import real MyParcelable in AIDL interface, nor I can import AIDL MyParcelable in Activity/Service...
AIDL experts, I need your help! Thanks in advance!
Please don't link me the official API guides, as there is nothing about it there http://developer.android.com/guide/components/aidl.html#PassingObjects