Skip to content Skip to sidebar Skip to footer

Install Android Apk Without Prompt

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 will be a

Solution 1:

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

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

OR

Please check http://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/

Solution 2:

publicvoidInstallAPK(String filename){

    Processprocess= Runtime.getRuntime().exec("su");
    OutputStreamout= process.getOutputStream();
    Stringreinstall="pm install -r " + filename + "\n";
    Stringam="am start -a android.intent.action.MAIN -n yourPackage/.MainActivity";
    Stringcmd= reinstall + am + " &";
    out.write(cmd.getBytes());
    out.flush();
    out.close();
    process.waitFor();

}

Post a Comment for "Install Android Apk Without Prompt"