android dexclassloader类加载器

InputStream is = this.getAssets().open("classes.jar");
String dexPath = "/data/data/"+this.getPackageName()+"/";
FileOutputStream fos = new FileOutputStream(dexPath + "classes.jar");
byte[] buffer = new byte[1024];
int i = 0;
while((i=is.read(buffer))!=-1){
fos.write(buffer, 0, i);
}
fos.flush();
fos.close();
is.close();
Log.e("test", "111");
DexClassLoader dexClassLoader = new DexClassLoader(dexPath + "classes.jar", dexPath, null, this.getClassLoader().getParent());

Object currentActivityThread = RefInvoke.invokeStaticMethod(
"android.app.ActivityThread", "currentActivityThread",
new Class[] {}, new Object[] {});
String packageName = this.getPackageName();
HashMap mPackages = (HashMap) RefInvoke.getFieldOjbect(
"android.app.ActivityThread", currentActivityThread,
"mPackages");
WeakReference wr = (WeakReference) mPackages.get(packageName);

RefInvoke.setFieldOjbect("android.app.LoadedApk", "mClassLoader",
this.getClassLoader(), dexClassLoader);

android dexclassloader类加载器,布布扣,bubuko.com

android dexclassloader类加载器

上一篇:工程中添加Android Dependencies


下一篇:自译教程:移动客户端设计开发经验(1)-流程篇(原创) 站酷推荐文章