[Android Software Development] cicada:
Hi all,

I'm new to Android development, kind of a Java noob, but not to programming in general. I'm not looking for code examples, just theory or a basic 'how this is done' in Java/Android. I also hope this will become useful information for other developers heading down this path.

I've had some success creating my first Android app - I apologize for not going into details about the specifics of the app, as I plan to eventually sell it commercially on the market - the question should, however, be applicable to any application using this flow model.

My current goal for this application is to create a 'plugin' type system ( like those used in OpenHome and other apps that allow user-generated plugin-able content / functionality ), to allow for flexibility in both my own further component development, as well as eventually creating an open interface for other developers to use to extend the application.

Currently my application is laid out as follows:

Main UI class

- entry point to the application

- starts the service class to spawn 'spinners' ( data processors )

- presents the user with an (ideally) extendable interface to the service

- binds to the service class using AIDL

Service class

- presents an AIDL interface for communication from the UI process

- creates 'spinners' of various types based on user interaction that process data

- persistent, will run in background, new Main UI instances will connect to the running service and present the currently running spinners.

- extendable via an as-yet-unimplemented plugin interface to add new types of spinners

Spinner classes

- use a generic interface with a handfull of common methods to communicate with the Service class, bubbling up data to the UI interface.

- processes user defined data streams, outputs to a buffer/sink suppled by the Service

Assumptions I can make are:

- the plugin (Spinner) class will always implement / override a group of methods to present to the Service class; ie 'putData()', 'getStatus()', 'start()' and 'exit()'

- the plugin class should always return data to the Service class via a supplied/shared buffer ( short array, for example )

Where I'm stuck at the moment is exactly how to implement extendable classes without those classes being a part of the current code base package. More simply, how do I interface with these classes without knowing their names, methods, etc?

As mentioned, I'm new to Java so I may just be overlooking an already implemented class that handles this interaction. If that is the case, I'd be happy for anyone to tell me to shut up and read the docs, if you can point me at the proper docs ;)

What I really don't want to do is create a 'plugin language' for these external bits, as I feel this could hamper development of fast/functional plugins vs. those written as native Java classes. This would also expose potential security issues, as I'd need to create a public interface to the Service class for these applications to link to. I'd prefer if execution of the plugins remained private / internal to the 'main' application.

I'm already using an AIDL interface between the UI class and the Service class - it would potentially be possible to use further AIDL interfaces into each plugin, but from my romp-through-the-park implementing the UI -> Server communication in this way, I find it cumbersome and difficult to pass any kind of complex data sets/controls. And I'm still unsure how the Service class would actually implement these without inheriting the interface directly.

I've poked around Intents in Android, but I'm having trouble wrapping my head around them/what they're for - it seems it might be possible to inherit the plugins that define themselves as sinks for my applications specific Intent type, but I'm lost in the details of how this works exactly, or if it would even be a viable path for what I'm trying to do. Can new Intents even be introduced into Android?

I apologize for the long-winded explanation of what boils down to a simple question:

How can I implement a 'plugin' interface in my application to allow myself and other developers to extend my app through their own classes?