简体   繁体   English

可以从其apk运行应用程序

[英]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.

相关问题 是否可以从 IntelliJ IDEA 运行现有的 APK? - Is it possible to run an existing APK from IntelliJ IDEA? 从android应用程序内部运行apk - Run apk from inside android application 从Android Studio运行应用程序及其APK有什么区别? - What are the differences between running an application from Android studio, and its APK? 以root用户身份从Android APK运行“ dd”命令-可以吗? - Run 'dd' command from Android APK as root - is it possible? 有可能在Android中从RAM运行apk以获得更高的性能吗? - It's possible to run an apk from RAM in android for higher performance? 是否可以从android应用程序运行android应用程序? - Is it possible to run android application from android application? 如何从Android应用程序内部运行已安装的.apk文件? - how to run installed .apk file from inside android application? Android Studio:从 Run &#39;app&#39; 安装的应用程序和从 build/outputs/apk/debug/app-debug.apk 安装的应用程序是不同的 - Android Studio: The application installed from Run 'app' and application installed from build/outputs/apk/debug/app-debug.apk are different Android应用程序可以请求重新安装自己的APK吗? (来自安装服务) - Android Can an application request reinstallation of its own APK? (from installation service) 是否可以从手机构建 APK? - Is it possible to build APK from a phone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM