启用另一个程序某些方法

DexFile df = new DexFile(new File("/data/app/my_downloaded_lib.apk")); 
ClassLoader cl = getClassLoader(); 
Class clazz = df.loadClass("com/my/lib/MyClass", cl); 

2.cl = new DexClassLoader("/full/path/com.example.apk", 
                        getFilesDir
().getAbsolutePath(),// /data/data/foo/files 
                       
null,  // native lib path, I haven't used this 
                       
MyClass.class.getClassLoader()); 
// This doesn't make Class.forName() work, instead I do this: 
Class<?> foo = cl.loadClass("com.example.foo"); 
3.

PathClassLoader( "/data/app/org.startsmall.myapp.apk" ,
                 ClassLoader.getSystemClassLoader());
final String apkFiles =
             "/data/app/org.startsmall.myapp.apk:" + // myself
             // handlers defined by other developers
             "/data/app/" + handlerClassName.substring( 0 , lastDotPos) + ".apk" ;
  
         dalvik.system.PathClassLoader myClassLoader =
             new dalvik.system.PathClassLoader(
                 apkFiles,
                 ClassLoader.getSystemClassLoader());
  
          // ...
  
         try {
             Class<?> handler =
                 Class.forName(handlerClassName, true , classLoader);
  
             // Call reflective APIs.
  
        } catch (ClassNotFoundException e) {
             // .....

你可能感兴趣的:(方法)