如何实现对Android应用程序的子组件的模块化结构?

问题描述:

我的Andr​​oid主要应用将包括一个主程序,有几个pre-安装的模块。
然后,我想以后提供不同的模块,最好将其作为单独文件。模块,如:位置,天气,日程。

My Android main application will consist in a main program, with a few pre-installed modules.
Then I want to offer different modules later, best would be as separate files. Modules like: location, weather, agenda.

你将如何做到这一点?

我要保留在数据库中安装/ present模块。所以,我必须把有时模块到数据库,也许是如果有present在启动时检测。主要的应用程序将合作,开发基于这些模块。

I want to keep in the database the modules that are installed/present. So I must put sometimes the modules into database, maybe by detecting if there are present at launch time. The main app will work based on these modules.

如何建立这些模块作为单独的文件?他们会不会在我的应用程序的入口点。因此,他们不能在导航菜单中的应用程序。

How can I build these modules as separate files? They won't be an entry point in my application. So they must not be an application in the navigation menu.

这可能吗?
如何做我创建这个使用Eclipse?
在什么样的格式将我提供的模块?
如何将用户添加/删除模块?

Is this possible?
How do I have to create this using Eclipse?
In what format will I offer the modules?
How will the user add/remove modules?

的Andr​​oid可以让你松散耦合的应用与意图 ContentProviders ,所以它应该可以达到你所要寻找的。困难的部分将规划一切行动面前,让你的功能逻辑分区(等东西堵塞起来容易)。

Android allows you to loosely couple applications together with Intents and ContentProviders, so it should be possible to achieve what you're looking for. The hard part will be planning everything up front, so you have logical divisions of functionality (and so things plug together easily).

我要保留在数据库中安装/ present模块。所以,我必须把有时模块到数据库,也许是如果有present在启动时检测。主要的应用程序将合作,开发基于这些模块。

I want to keep in the database the modules that are installed/present. So I must put sometimes the modules into database, maybe by detecting if there are present at launch time. The main app will work based on these modules.

您可以注册一个的BroadcastReceiver ACTION_PACKAGE_ADDED ,每当一个新的应用程序安装,这将触发。你的主要应用程序应该能够使用这个来确定安装了额外的模块时。

You can register a BroadcastReceiver for ACTION_PACKAGE_ADDED, which will fire whenever a new application is installed. Your main application should be able to use this to determine when additional modules are installed.

在什么样的格式将我提供的模块?

In what format will I offer the modules?

您可能想还是打包模块,APKS这样他们就可以被上传到市场。如果你想他们不会出现在启动器(应用程序抽屉),你可以随时删除默认<意向滤光器>和应用程序将无法可启动的(但仍然是可移动的)。

You probably want to still package the modules as apks so they can be uploaded to the marketplace. If you want them to not appear in the launcher (the app drawer), you can always remove the default <intent-filter> and the app will not be launchable (but still be removable).

我如何要创建这个使用Eclipse?

How do I have to create this using Eclipse?

您模块仍然是独立的应用程序。

Your modules would still be standalone applications.

如何将用户添加/删除模块?

How will the user add/remove modules?

从市场上或直接下载从网上(如果你想)。

From the marketplace or direct downloads off of the web (if you want).