Android Install apk silently by busybox command-line

前端 未结 3 1698
猫巷女王i
猫巷女王i 2021-01-01 05:54

I want to install .apk silently in background by BusyBox command. I`ve seen some similar questions like THIS, but I still cant get working my code properly...

I have

3条回答
  •  长发绾君心
    2021-01-01 06:30

    You can simply use adb install command to install/update APK silently. Sample code is below

    public static void InstallAPK(String filename){
        File file = new File(filename); 
        if(file.exists()){
            try {   
                String command;
                filename = StringUtil.insertEscape(filename);
                command = "adb install -r " + filename;
                Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
                proc.waitFor();
            } catch (Exception e) {
            e.printStackTrace();
            }
         }
      }
    

提交回复
热议问题