GetForecastPage
As with a Java interface, you declare a package at the top. As with a Java interface, the methods are wrapped in an interface declaration (). And, as with a Java interface, you list the methods you are making available.
The differences, though, are critical.
First, not every Java type can be used as a parameter. Your choices are:
• Primitive values (, , , , etc.)
• and
• and (from )
• Any other AIDL‑defined interfaces
• Any Java classes that implement the interface, which is Android’s flavor of serialization
In the case of the latter two categories, you need to include import statements referencing the names of the classes or interfaces that you are using (e.g., import ). This is true even if these classes are in your own package – you have to import them anyway.
Next, parameters can be classified as , , or . Values that are out or can be changed by the service and those changes will be propagated back to the client. Primitives (e.g., ) can only be ; we included in for the AIDL for just for illustration purposes.
Also, you cannot throw any exceptions. You will need to catch all exceptions in your code, deal with them, and return failure indications some other way (e.g., error code return values).
Name your AIDL files with the extension and place them in the proper directory based on the package name.
When you build your project, either via an IDE or via Ant, the utility from the Android SDK will translate your AIDL into a server stub and a client proxy.
Дата добавления: 2015-05-16; просмотров: 654;