Stack Overflow archive
1 score

Is it possible to create a silent installer on a stock ROM rooted device?

score
1
question views
961
license
CC BY-SA 3.0

You can use an open source library to run the command as root. Check out the following libraries:

https://github.com/Stericson/RootTools

https://github.com/SpazeDog/rootfw

https://github.com/Chainfire/libsuperuser

https://github.com/dschuermann/superuser-commands

Or do it yourself:

java
Process su = null;
try {
    su = Runtime.getRuntime().exec("su");
    String cmd = "pm install /path/to/the/apk\n";
    su.getOutputStream().write(cmd.getBytes());
    String exit = "exit\n";
    su.getOutputStream().write(exit.getBytes());
    su.waitFor();
} catch (Exception e) {
    e.printStackTrace();
} finally {
    if (su != null) {
        su.destroy();
    }
}

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.