Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A callback method/listener is the right thing to do. (As CommonsWare says, it's pretty much the same thing). I would say it's much simpler than fiddling around with BroadcastReceivers, since you're already using aidl.</p> <p>Something like this:</p> <p><strong>IAsyncThing.aidl:</strong></p> <pre><code>package com.my.thingy; import com.my.thingy.IAsyncThingListener; interface IAsyncThing { void doSomething(IAsyncThingListener listener); } </code></pre> <p><strong>IAsyncThingListener.aidl:</strong></p> <pre><code>package com.my.thingy; import com.my.thingy.IAsyncThingListener; interface IAsyncThingListener { void onAsyncThingDone(int resultCodeIfYouLike); } </code></pre> <p>You can enforce that only your apps can bind to the service by using a signature-level permission on your service (see the note on 'service permissions' here: <a href="http://developer.android.com/guide/topics/security/permissions.html">http://developer.android.com/guide/topics/security/permissions.html</a>). Specifically:</p> <ul> <li>Declare a permission in your service's <code>AndroidManifest.xml</code>. Ensure it is <code>signature</code> level.</li> <li>Add that permission in your <code>service</code> tag</li> <li>In all the other apps, use <code>uses-permission</code> to use it.</li> </ul> <p>A couple of other things to bear in mind:</p> <ul> <li>In the caller, you'll need to subclass <code>IAsyncThingListener.Stub</code>. Your calling application code may already be subclassing something else, so that means you'd have to use an extra (probably inner) class to receive the completion notification. I mention this only because this might be the answer to question #2 - which I don't fully understand.</li> <li>If the service is potentially in different processes from the caller, each should register for death notification of the other using <code>IBinder.linkToDeath</code>.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload