如何在Android上实现app子组件的模块化结构? [英] How to achieve modularity structure of app subcomponents on Android?

查看:31
本文介绍了如何在Android上实现app子组件的模块化结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Android 主应用程序将包含在一个主程序中,其中包含一些预安装的模块.
然后我想稍后提供不同的模块,最好是作为单独的文件.模块如:位置、天气、议程.

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.

您将如何实现这一目标?

How would you accomplish this?

我想将已安装/存在的模块保留在数据库中.所以我有时必须将模块放入数据库中,也许是通过检测启动时是否存在.主应用将基于这些模块运行.

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?

推荐答案

Android 允许您将应用程序与 IntentsContentProviders 松散耦合在一起,因此应该可以实现您的目标.困难的部分是预先计划好所有事情,这样您才能对功能进行逻辑划分(这样可以轻松地将事情整合在一起).

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).

我想将已安装/存在的模块保留在数据库中.所以我有时必须将模块放入数据库中,也许是通过检测启动时是否存在.主应用将基于这些模块运行.

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.

您可以为 ACTION_PACKAGE_ADDED 注册一个 BroadcastReceiver,它会在安装新应用程序时触发.您的主应用程序应该能够使用它来确定何时安装其他模块.

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?

您可能仍希望将模块打包为 apk,以便将它们上传到市场.如果您不希望它们出现在启动器(应用程序抽屉)中,您可以随时删除默认的 <intent-filter>并且该应用将无法启动(但仍可移除).

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).

这篇关于如何在Android上实现app子组件的模块化结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆