01.11.2014 Views

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

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

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

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

AIDL (Android Interface Definition Language)<br />

Calling an IPC Method<br />

Here are the steps a calling class should make to call your remote interface:<br />

1. Declare a variable of the interface type that your .aidl file defined.<br />

2. Implement ServiceConnection.<br />

3. Call Context.bindService(), passing in your ServiceConnection implementation.<br />

4. In your implementation of ServiceConnection.onServiceConnected(), you will receive an<br />

IBinder instance (called service). Call YourInterfaceName.Stub.asInterface((IBinder)service)<br />

to cast the returned parameter to YourInterface type.<br />

5. Call the methods that you defined on your interface. You should always trap<br />

DeadObjectException exceptions, which are thrown when the connection has broken; this<br />

will be the only exception thrown by remote methods.<br />

6. To disconnect, call Context.unbindService() with the instance of your interface.<br />

A few comments on calling an IPC service:<br />

• Objects are reference counted across processes.<br />

• You can send anonymous objects as method arguments.<br />

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

15

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

Saved successfully!

Ooh no, something went wrong!