Android 应用程序的插件管理
我们想要开发可扩展的Android应用程序,并且正在寻找一种处理插件的方法。
您认为最好的方法是什么:
使用 Android 的 PackageManager。这里的问题是 PM 的设计并没有考虑到插件,因此我们必须自己实现依赖项检查等功能。
使用现有的 Java 框架,例如 JPF(Java 插件框架)或 OSGi。 OSGi 对我们来说看起来太大了,并且没有太多关于 Android 上的 JPF 的信息。
其他想法?
We want to develop and extensible Android application, and are looking for a way to handle plugins.
What do you think would be the best approach:
Using Android's PackageManager. The problem here is that the PM isn't designed with plugins in mind, so we'd have to implement functionalities such as dependency checks ourselves.
Using an existing Java framework such as JPF (Java Plugin Framework) or OSGi. OSGi looks too massive for us, and there's isn't too much information available about JPF on Android.
Other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一种方法是使用 OSGi 框架。我不确定您是否熟悉它,但它允许您使用组件(称为捆绑包)构建应用程序,并且可以安装、更新和卸载这些组件,而无需停止其他组件。 OSGi 经常用于创建完全模块化的应用程序,或为现有应用程序创建插件机制。
OSGi 有多种开源实现。 Apache Felix 在 Android 上开箱即用,将其嵌入到您的应用程序中也相当容易。
如果您有兴趣,我可以提供更多指导,因此请随时跟进此答案。
A different approach could be using the OSGi framework. I'm not sure if you're familiar with it, but it allows you to build your application out of components (called bundles) and those can be installed, updated and uninstalled without having to stop other components. OSGi is used a lot to create either completely modular applications, or to create a plugin mechanism for existing applications.
There are several open source implementations of OSGi. Apache Felix runs out of the box on Android, and embedding it in your application is fairly easy as well.
If you're interested, I can provide more pointers, so feel free to follow up on this answer.
“插件”到底是什么意思?通过
Intent
和IntentFilter
概念,您已经可以做很多我称之为“插件”的事情。例如,您可以允许其他应用程序在您的上下文菜单中添加条目。What exactly do you mean with "plugin"? With the
Intent
andIntentFilter
concept you can already do many things I would call "plugin". For example, you can allow other applications to add entries in your context menu.