5

We want to develop and extensible Android application, and are looking for a way to handle plugins.

What do you think would be the best approach:

  • Using Android's PackageManager. The problem here is that the PM isn't designed with plugins in mind, so we'd have to implement functionalities such as dependency checks ourselves.

  • Using an existing Java framework such as JPF (Java Plugin Framework) or OSGi. OSGi looks too massive for us, and there's isn't too much information available about JPF on Android.

  • Other ideas?

MasterScrat
  • 7,090
  • 14
  • 48
  • 80

2 Answers2

5

What exactly do you mean with "plugin"? With the Intent and IntentFilter concept you can already do many things I would call "plugin". For example, you can allow other applications to add entries in your context menu.

Christian Gawron
  • 852
  • 1
  • 6
  • 18
  • Yes that's what I mean by "using Android's PackageManager": having one application per plugin. But it's definitely not perfect as for example 12 plugins would mean 12 app installed on the phone... – MasterScrat Feb 13 '11 at 18:57
  • 1
    After learning more on the subject we ended up doing something like this in the end. – MasterScrat Apr 06 '11 at 12:46
4

A different approach could be using the OSGi framework. I'm not sure if you're familiar with it, but it allows you to build your application out of components (called bundles) and those can be installed, updated and uninstalled without having to stop other components. OSGi is used a lot to create either completely modular applications, or to create a plugin mechanism for existing applications.

There are several open source implementations of OSGi. Apache Felix runs out of the box on Android, and embedding it in your application is fairly easy as well.

If you're interested, I can provide more pointers, so feel free to follow up on this answer.

Marcel Offermans
  • 3,313
  • 1
  • 15
  • 23
  • Yes OSGi is one of the solution we're considering. My concern is that it'd be too big for our needs, do you know how much space Felix takes once installed? also would OSGi be fast enough on a mobile device? – MasterScrat Feb 14 '11 at 02:12
  • 1
    The framework itself has a disk footprint of about 400k. At runtime the memory requirements largely depend on the number of bundles / plugins you install. I don't have any concrete numbers, but its quite easy to do an experiment. From experience I can tell that Felix runs well on Android. The OSGi specification was meant to run on embedded devices, most of which were way less powerful than a modern smartphone running Android. – Marcel Offermans Feb 14 '11 at 13:31