How to return MyObject list in android help file?

I have this method in a .aidl file:

void getObjects(out List<MyObject> objList);

But I get this error

src / com / mycompany / mypackage / ITestService.aidl: 26 parameter objList (1) unknown type List objList

How to create a MyObject list in .aidl?

Thanks.

+3
source share
2 answers

Steps:

  • MyObject implements Parcable

  • Create a new MyObject.aidl file at src.com.mycompany.mypackage

      package src.com.mycompany.mypackage;
      parcelable MyObject;
    

    Reason: you transfer class objects between processes, the client process must understand the definition of the transferred object.

    AIDL complier will not be able to find our self-defined MyObject, even if it implements the Parcelable interface. To report our implementation to the AIDL compiler, we need to define a helpl file that declares the Parcelable class

  • ITestService.aidl ,

    import src.com.mycompany.mypackage.MyObject
    

. .

+3

Source: https://habr.com/ru/post/1718327/


All Articles