Droid Plugin 详细介绍
DroidPlugin 是360手机助手在 Android 系统上实现了一种新的插件机制:它可以在无需安装、修改的情况下运行APK文件,此机制对改进大型APP的架构,实现多团队协作开发具有一定的好处。
HOST程序:插件的宿主。
插件:免安装运行的APK
在host中集成Droid Plugin项目非常简单:
我们只是需要将Droid Plugin当作一个lib工程应用到主项目中,然后:在AndroidManifest.xml中使用插件的com.morgoo.droidplugin.PluginApplication: <application android:name="com.morgoo.droidplugin.PluginApplication" android:label="@string/app_name" android:icon="@drawable/ic_launcher" 如果你使用自定义的Application,那么你需要在自定义的Application class onCreate和attachBaseContext方法中添加如下代码: @Override public void onCreate() { super.onCreate(); //这里必须在super.onCreate方法之后,顺序不能变 PluginHelper.getInstance().applicationOnCreate(getBaseContext()); } @Override protected void attachBaseContext(Context base) { PluginHelper.getInstance().applicationAttachBaseContext(base); } 将插件中LibrariesDroidPluginAndroidManifest.xml中所有的provider对应的authorities修改成自己的,默认为com.morgoo.droidplugin_stub_P00,如下: <provider android:name="com.morgoo.droidplugin.stub.ContentProviderStub$StubP00" android:authorities="com.morgoo.droidplugin_stub_P00" android:exported="false" android:label="@string/stub_name_povider" />可以修改为自己的包名,如: com.example.droidplugin_stub_P00 防止跟其它本插件使用者冲突:
<provider android:name="com.morgoo.droidplugin.stub.ContentProviderStub$StubP00" android:authorities="com.example.droidplugin_stub_P00" android:exported="false" android:label="@string/stub_name_povider" /> 集成完成。请参见源码
文章转载自 开源中国社区[https://www.oschina.net]
相关资源:敏捷开发V1.0.pptx