android插件化开发的框架,实现apk动态加载: Android PluginManager
jopen
10年前
动态加载未安装的apk。
介绍
PluginManager可用于管理Android应用程序,就像eclipse插件一样。你可以从放在sdcardk中的一个未安装apk启动一个activity,就像它已经安装或已经在application的AndroidManifest.xml中注册一样。
支持的特性
- a normal apk is regard as plug-in
- start activity from plug-in
- start other activiy from plug activity
- plug activity with theme
- plug with customApplication
- plug with .so
-
support android2.x
it's easy to use:
Steps:
-
declare permission in yourAndroidManifest.xml:
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-
regist an activity
<activity android:name="androidx.pluginmgr.PluginActivity" />
-
load plugin from plug apk:
PluginManager pluginMgr = PluginManager.getInstance(MyActivity); File myPlug = new File("/mnt/sdcard/Download/myplug.apk"); PlugInfo plug = pluginMgr.loadPlugin(myPlug).iterator().next();
- start activity:pluginMgr.startMainActivity(context, plug.getPackageName());