Android applications call Aidl

Source: Internet
Author: User

Project requirements: 1. Create a system application TestAPP. The application starts a service after it is started. The service provides data interfaces for other applications.

2. Add a method to the acitivity source code and call the TestAPP method in the system application for data interaction.


1. Add the aidl file under the frameworks/base/core/java/android/app/directory:

IHelloWorld. aidl:

Package android. app;

Import java. lang. String;

Interface IHelloWorld

{

Void printHelloWorld ();

Void printString (String string );

}

Note:

(1) The package declaration of this file should be: package android. app;


2. Modify the Android. mk file under frameworks/base:

In "LOCAL_SRC_FILES + = \", see how to add IAlarmManager:

Core/java/android/app/IAlarmManager. aidl \

Add the following content at the end of "LOCAL_SRC_FILES + =:

Core/java/android/app/IHelloWorld. aidl,

Note:

(1) Add "\" to the end of the line above core/java/android/app/IHelloWorld. aidl.


3. After compiling framewor, find the classes. jar file under framework_intermediates under the \ out \ target \ common \ obj \ JAVA_LIBRARIES \ path (source code root path.

4. Add a new User Library in eclipse. For example, the name is android-lib (you can name it yourself)

5. Set this android-lib to System library and import the classes. jar file. (my colleague said that the System library is selected to allow the jar file to only be compiled and not run)

6. Add the new android-lib to the project, and set the order of android-lib to be higher than Android4.4 in Java Build path (for specific versions, refer to the project)


After completing the preceding steps, you can apply AIDL to the project.


If you want to use your own parcelable class in AIDl

The FriendInfo. java class implements Parcelable.

Generate FriendInfo. aidl in the same directory

For more information, see PendingIntent in frameworks/base/core/java/android/app /.



<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + CsztvNPN6rrzo6zQ6NKq1No8L3A + large/dPDPC9wPgo8cD4KPGJyPgo8L3A + CjxwPgqyzr + small "http://www.2cto.com/uploadfile/Collfiles/20140329/2014032910513826.jpg" alt = "">


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.