1

I want to know if an android app of mine can be extended by third parties without me having to modify the base app for each extension, kind of what eclipse does with its plug-ins.

The base app would be something pretty simple, some kind of local data manager (CRUD operations). A given plug-in may, for example, do things with said data (different ways of displaying it, for instance) in additional activities/fragments.

From a little research around, I've discovered that if I were to be the developer of both base app and plug-ins, I could accomplish it by creating new apks non directly accessible for the user (Main/Launcher) and querying from the base app whether a given plug-in is installed on the device and, if so, show additional options on the UX. I can work with that, but I wondered if there was no other option to allow the third-party extension.

Searching for "extension points" doesn't seem to yield android results. Maybe it isn't possible?

Frank
  • 2,777
  • 5
  • 18
  • 30

2 Answers2

3

A given plug-in may, for example, do things with said data (different ways of displaying it, for instance) in additional activities/fragments.

Step #1: Expose said data to third-party apps, such as via a ContentProvider.

Right now, you're already done, except for the part of "show additional options on the UX". For that:

Step #2: Document the <intent-filter> that third-party apps should have on any activities that they want to be launched from your app. This may involve custom actions and/or categories and/or MIME types.

Step #3: When your needs to "show additional options on the UX" (which I am interpreting as some sort of list or menu), use queryIntentActivities() on PackageManager to find all activities that implemented the <intent-filter> that you documented in Step #2, and include them in that list.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

For your particular scenario, where it's simply a matter of storing and retrieving data from a base application, you can use the same approach as the Contacts application uses, which uses a Content Provider.

You can read more about Content Providers and how to implement them here: Content Providers | Android Developers

If you're instead looking at extending an installed application, you would have to predefine a dynamic set of classes to present the data, as well as a set of rules and a language / interface for the plug-ins to extend your applications functionality from within your own application.

You could also look into loading external .jar files into your application at runtime. It looks like others have been successful before

Community
  • 1
  • 1
Nicklas Jensen
  • 1,424
  • 12
  • 19