https://github.com/singwhatiwanna/dynamic-load-apk
http://blog.csdn.net/singwhatiwanna/article/details/39937639
这里是插件是apk的一种实现方式
插件式activity 包装代理实现的方式 ,activity 生命周期的方法做对应调用;
apk中的资源也做了 也可以特别指定,特别加载。
private AssetManager createAssetManager(String dexPath) {
try {
AssetManager assetManager = AssetManager.class.newInstance();
Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
addAssetPath.invoke(assetManager, dexPath);
return assetManager;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
........................
private Resources createResources(AssetManager assetManager) {
Resources superRes = mContext.getResources();
Resources resources = new Resources(assetManager, superRes.getDisplayMetrics(), superRes.getConfiguration());
return resources;
}
@Override
protected void onStop() {
mRemoteActivity.onStop();
super.onStop();
}
@Override
protected void onDestroy() {
mRemoteActivity.onDestroy();
super.onDestroy();
}
....................
附件为 主工程代码 ,更详细的参照链接文档。。
android 插件实现
猜你喜欢
转载自lyp2002924.iteye.com/blog/2237612
今日推荐
周排行