1. listview列表url
2.下载url apk文件
3. 安装apk
4.监听安装应用广播
android.intent.action.package_added
插件管理类获取包名并管理。
5. 调用插件中的方法
使用
1.
context.createPackageContext(包名,
Context.CONTEXT_INCLUDE_CODE
| Context.CONTEXT_IGNORE_SECURITY
)获取包的context。
2.
用反射的方式实例化插件中的接口类,加入参数。
完成连接。
Context c = getContext().createPackageContext(“插件包名”,Context.CONTEXT_INCLUDE_CODE |Context.CONTEXT_IGNORE_SECURITY);
Class<?> clazz = c.getClassLoader().loadClass(插件接口类)
Constructor<?> con = con = clazz.getConstructor(“插件接口类需要的参数,如view,context等等”);
con.newInstance();
3.
如果是换皮肤可用。
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">注:插件中的资源名字是约定好的</span>
Context c = getContext().createPackageContext(“插件包名”,Context.CONTEXT_INCLUDE_CODE |Context.CONTEXT_IGNORE_SECURITY);
Resource r = c.getResources();
String name = “本地context”.getResources().getResourceEntryName(localResId);
String resType = “本地context”.getResources().getResourceTypeName(localResId);
int matchId = c.getIdentifier( resName, resType, “插件包名”);
Bitmap bitmap = BitmapFactory.decodeResource(r, matchId);
BitmapDrawable bd = new BitmapDrawable(bitmap);
setBackgroundDrawable(bd);