views:

113

answers:

2

I am doing a keyboard for Android. I am willing to have a plugin structure to allow users to improve the prediction engine.

The prediction engine is done with Android NDK and it was coded in C. I have a wrapper class that calls the C code. An instance of this wrapper class is a field in the InputMethodService. The prediction engine gets updated by sending complete sentences. Something like:

public void updateEngine(String sentence);

Plugins should be calling that method. An example of the plugin can be a .txt parser. You select a txt file and the plugin will start sending to the main app all sentences. I would like plugins to be customizable, e.g.: They might have an screen where you can choose max sentence to send, to run on background, etc. The UI (don't know if it should be on the main app or the plugin, check my questions below) should have the possibility to ask the plugin how many sentence it can send (to do a progress bar).

My questions are:

  • Should I use Intents or IPC?

I think I should use Intents since I just use primitive types.

  • Should my operations be atomic or send an array of sentences?

I am willing to start with atomic operations but I am worried about performance.

  • The plugins must be activities or Services?

They should be Activities and if necessary ("process on background" on) launch a service. Or perhaps they are just services and the main app takes care of the UI.

  • Who should save information about the last execution. Plugin or the mainApp?

e.g. When was the last time the plugin was used.

+1  A: 

Should I use Intents or IPC?

Either works. Intents may be simpler.

Should my operations be atomic or send an array of sentences?

I'd bundle these up into a single operation if possible. Lots of little cross-process trips is more expensive than one large one, as I understand it.

The plugins must be activities or Services?

You appear to want the plugin to call into the engine, which is fine, but...when? Plugins won't get control automatically at install time. The choice of trigger mechanism for the plugin calling into the engine will dictate whether the plugin needs an activity or not.

Who should save information about the last execution. Plugin or the mainApp?

This doesn't make a lot of sense to me given the rest of what you have here, so I can't comment. This may roll back to the lack-of-trigger issue I mention above. For example, under what circumstances would a plugin ever be used more than once?

CommonsWare
They are triggered by a setting menu in the main app. Just like BetterKeyboard do it with skins.Used more than once it's totally possible. I guess if an email plugin is created, I would like to update itself always.
Macarse
A: 

I found a good article about this:

Macarse