3

I am developing an application that should be extendable I want the user to install the base app and then extend it by installing extension packs (different APKs) or plug-ins (like go launcher and theme-packs or add-on widgets)

The only thing I could find is using library project to share the code but that doesn't fit my needs. Can someone explain how its done?

[edit] To be more specific, here is what I want to do: I have a set of animated scenes, effects and transitions animated scene is a combination of code and resources The user can select the 1st scene, 2nd scene etc..

I wish to be able to add more scenes but I don't want to include them all in one APK I want to let the user download scenes of his choice.

Nir
  • 1,608
  • 1
  • 17
  • 29

2 Answers2

4

To build this type of interaction, ContentProvider will be your friend. There are two options I can think of to build this type of system, depending on which direction you would like information to flow.

Option 1: Single ContentProvider in main application

Define a ContentProvider in your main application, which creates an external interface for other applications to read/write data to a common location. This provider maintains access to the scene data files/database your application needs.

Each subsequent plugin application accesses the main ContentProvider (and also warns the user if they run a plugin but haven't installed the main app yet) and installs its specific content by writing it to the ContentProvider. In this way, each plugin is designed to act as an "installer", meaning the user has to download and run the plugin from Market to install the scene content.

Option 2: Each "Plugin" application has its own ContentProvider

This option is the reverse of the above. Define a ContentProvider with a consistent interface in each plugin application and have a method from the main application that scans the system for new plugins (this can be done via PackageManager) and reads the data from each provider into its main local store.

The difference here is that the user won't have to run each plugin package, because the main application will take care of getting the data. However, there's more complexity in defining multiple providers. For instance, you have to make sure that, even if each provider has the same basic interface, they cannot have a single common authority, so you will have to scan the system for package names like your own and resolve the providers based on that information.

Editorial

Having said that, I feel I should mention that I don't believe this is a good method of providing content to your users. My personal feeling on the subject is this method pollutes the user's devices with application icons that do them no good, and it's difficult to hide that kind of thing on the mobile device. A simpler, and much cleaner approach to this would be to store your "add-on" content on a server (AWS services like S3 and SimpleDB are practically free) and use a service like Google's In-App Billing to let your users purchase the new content and download it directly into the single application rather than having them go back to Market and purchase more apps.

Hope that Helps!

devunwired
  • 62,780
  • 12
  • 127
  • 139
  • I find it problematic that when you define a content provider, it must be a unique name, so your application must be quite unique in the pool with other applications out there. Can the same affect be achieved using broadcasts and intent-filters? –  Nov 18 '11 at 14:56
  • 1
    Thanks for the detailed explanation, a content server or in app billing are a good ideas. However, I see popular apps taking the multiple APKs approach without having multiple icons. like "elixir" with extension plug-ins and go products like "go launcher" with themes/widgets etc. I prefer the simplest solution. I also think that using market to host my plugins is a good way to promote favorite plug-ins and get free statistics. – Nir Nov 18 '11 at 20:42
  • You can install your "plugin" apps without a Launcher icon by not providing an Activity that responds to the `android.intent.action.MAIN` + `android.intent.category.LAUNCHER` in the manifest. You will still have to create the `ContentProvider` one direction or the other to transfer the content data. – devunwired Nov 18 '11 at 21:33
0

I have a set of animated scenes, effects and transitions animated scene is a combination of code and resources The user can select the 1st scene, 2nd scene etc..

If the "animated scenes" are activities. your add-on APKs simply publish their own sets of activities, and you use PackageManager to determine which of your plugins are installed and how to use them.

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