01.11.2014 Views

The AndroidManifest.xml File - 안드로이드 기술 커뮤니티 : Korea ...

The AndroidManifest.xml File - 안드로이드 기술 커뮤니티 : Korea ...

The AndroidManifest.xml File - 안드로이드 기술 커뮤니티 : Korea ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AIDL (Android Interface Definition Language)<br />

Implementing IPC Using AIDL : Implementing the Interface<br />

AIDL generates an interface file for you with the same name as your .aidl file. If you are using<br />

the Eclipse plugin, AIDL will automatically be run as part of the build process (you don't need to<br />

run AIDL first and then build your project). If you are not using the plugin, you should run AIDL<br />

first.<br />

<strong>The</strong> generated interface includes an abstract inner class named Stub that declares all the<br />

methods that you declared in your .aidl file. Stub also defines a few helper methods, most<br />

notably asInterface(), which takes an IBinder (passed to a client's onServiceConnected()<br />

implementation when applicationContext.bindService() succeeds), and returns an instance of<br />

the interface used to call the IPC methods. See the section Calling an IPC Method for more<br />

details on how to make this cast.<br />

To implement your interface, extend YourInterface.Stub, and implement the methods. (You can<br />

create the .aidl file and implement the stub methods without building between--the Android<br />

build process will process .aidl files before .java files.)<br />

Here is an example of implementing an interface called IRemoteService, which exposes a single<br />

method, getPid(), using an anonymous instance:<br />

private final IRemoteService.Stub mBinder = new IRemoteService.Stub(){<br />

public int getPid(){<br />

return Process.myPid();<br />

}<br />

}<br />

<strong>Korea</strong> Android Community- www.kandroid.org<br />

10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!