I have a service that regularly queries a web server for new messages. The service stores the new messages in an arrayList. These messages are implemented using a custom class, storing all kinds of metadata (strings and longs).
An activity then connects to this service to retrieve those messages and display them to the user.
I have an .aidl file that describes the interface that the service exposes.
package com.example.package;
interface MyInterface {
List<Message> getMessages();
}
The Message class extends the Parcelable class which should allow for the IPC transfer.
The problem is this: Eclipse gives me an error saying that the type of List<Message> is unknown. Any imports are marked as invalid.
Ideas? Thanks
Why? You only need that for a remote service, and you only need a remote service if you are exposing an API to third-party applications.
If your service is a local service, get rid of the AIDL and use the local binding pattern instead.
If you truly do need AIDL, then you should be able to explicitly import your
Parcelableclass in your AIDL file, so it can be referenced. Your AIDL interface shown above does not have this import statement — while it might not be needed for ordinary Java, it is needed for AIDL, since AIDL does not auto-import classes.