8

I want to share an interface via AIDL with client applications. I have been getting compile time errors. The code snippet is :-

interface ChildListener extends ParentListener {

    public void onUpdate(Class1  c1);
}

AIDL Set(All in the same package) -->

ChildListener.aidl - Contains the above code.

Class1.aidl - Declares Class1 as parcelable. Definition of Class1 implements parcelable.

ParentListener.aidl - Declares ParentListener.

Errors -->

I am getting compile time errors (while compiling service)

1. syntax error don't know what to do with "extends"
2. syntax error don't know what to do with "ParentListener "

It seems that we can not use inheritance in AIDL interfaces? Or is it that I am missing something here. Any pointers would be appreciated.

Best Regards

Robin
  • 497
  • 5
  • 19

1 Answers1

4

You cannot use extend when you declare aidl interface. Aidl interface is of special format. It even does not correspond to java interface declaration.

If you specify what you want to do we will try to point you how to solve the problem.

Yury
  • 20,618
  • 7
  • 58
  • 86
  • Yes, aidl interfaces does not support inheritance. I figured that out. Thanks for the answer. For anyone else who wants to use aidl ---> 1). for data classes, when you make a class parcelable, you can handle the parent data members in the writeToParcel & static CREATOR fields. 2). For interfaces, drop all inheritance(if you are trying to reuse the existing design in aidl) to expose the mechanism to share the data classes in the simplest possible manner. – Robin Jan 10 '12 at 17:19