Search code examples
javaandroidaidl

How to call AIDL services on app startup


My app is called MyNiceApp. MyNiceApp is mostly just a core that loads a CORE view which gets populated by other plugins which the user downloads as wishes. I define the various areas on the core view that can be populated by the plugins via Interfaces in MyNiceApp. How can I load apps that implement these interfaces via AIDL when the app starts?

Thank you all in advance.

UPDATE

Any other approach that could help achieve this functionality would suffice. It does't have to be only implementable via AIDL only.


Solution

  • Call bindService(), using an explicit Intent that identifies the plugin's exported service.

    To identify what plugins exist, use PackageManager and queryIntentServices() to find all apps that have a service with some <intent-filter> tied to your app. Confirm that the apps implementing the matches are who they say they are, via signature checks. Then, you can use the ResolveInfo from queryIntentServices() to construct the explicit Intent for binding.

    This pair of sample apps demonstrates the basic process. In my case, I am expecting exactly one match, whereas you perhaps are expecting N matches.