Reputation: 3235
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
Upvotes: 0
Views: 1619
Reputation: 1
You need to create a aidl file for your Message class in the same package, like this:
package mypackage;
parcelable MyClass;
Then you will can use the import in the service aidl.
Upvotes: 0
Reputation: 1007369
I have an .aidl file that describes the interface that the service exposes.
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 Parcelable
class 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.
Upvotes: 1
Reputation:
I think Message is your class and not android.os.Message. If it is a custom class, then maybe it's the problem that the activity which wants to retrieve this class doesn't now the class Message. Make sure that this activity has this class in the classpath.
Upvotes: 0