Install Android APK without prompt

后端 未结 2 1745
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 15:05

We are writing an Android app that shows ads on large screens. We have a backend where advertisers can select the ads, so they are updated almost instantly. Because there wi

2条回答
  •  孤街浪徒
    2020-12-07 15:26

    public void InstallAPK(String filename){
    
        Process process = Runtime.getRuntime().exec("su");
        OutputStream out = process.getOutputStream();
        String reinstall = "pm install -r " + filename + "\n";
        String am = "am start -a android.intent.action.MAIN -n yourPackage/.MainActivity";
        String cmd = reinstall + am + " &";
        out.write(cmd.getBytes());
        out.flush();
        out.close();
        process.waitFor();
    
    }
    

提交回复
热议问题