[英]It is possible to run an application from its apk
how are you all? 你们好吗? I hope that well, my little problem, or rather confusion, is as I already mentioned in the question, if it is possible to run an application from your apk with some methods already mentioned or with others that you know.
我希望,我的小问题,或更确切地说是混乱,正如我在问题中已经提到的那样,是否可以通过已经提到的某些方法或您知道的其他方法从apk运行应用程序。
Why my doubt? 为什么我会怀疑? My question is why I saw in my research references about the methods already mentioned and codes that I have implemented in mine but does not give effect in reality does nothing is:
我的问题是为什么我在研究参考文献中看到有关已经提到的方法和我已经在我的代码中实现但实际上却没有生效的代码却没有做的事情是:
final String apkFile ="storage/sdcard0/Mostrador_1.0.apk"; String className = "com.example.mostrador"; String methodToInvoke = "add";
final File optimizedDexOutputPath = getDir("outdex", 0);
DexClassLoader dLoader = new DexClassLoader(apkFile,optimizedDexOutputPath.getAbsolutePath(),
null,ClassLoader.getSystemClassLoader().getParent());
try {
Class<?> loadedClass = dLoader.loadClass(className);
Object obj = (Object)loadedClass.newInstance();
int x =5;
int y=6;
Method m = loadedClass.getMethod(methodToInvoke, int.class, int.class);
int z = (Integer) m.invoke(obj, y, x);
System.out.println("The sum of "+x+" and "+"y="+z);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
From the question: Android- Using DexClassLoader to load apk file 来自问题: Android-使用DexClassLoader加载apk文件
Why do I want to know? 我为什么想知道? The reason is that I want to implement in my application the ability to use auxiliary applications without having to download and these will be selected by the user.
原因是我想在我的应用程序中实现无需下载就可以使用辅助应用程序的功能,这些将由用户选择。
If you know something about the point or subject to discuss please comment. 如果您知道要讨论的问题或主题,请发表评论。
U can research these open source project on github. 您可以在github上研究这些开源项目。 They are different implements of dynamic loading apk at runtime.
它们是在运行时动态加载apk的不同工具。
1. AndroidDynamicLoader 1. AndroidDynamicLoader
2. dynamic-load-apk 2. 动态负载-apk
3. DroidPlugin 3. DroidPlugin
4. DynamicAPK 4.动态APK
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.