Install / Unistall from shell command in Android

后端 未结 6 1775
一生所求
一生所求 2020-12-28 20:55

I want to implement a silent installer-from-apk-file and unistaller-package in Android. The topic has largely been discussed on SO and elsewhere but I can\'t apply any for s

6条回答
  •  -上瘾入骨i
    2020-12-28 21:34

    Installing in the /system/app directory is essentially the same as requiring root.

    Assuming you have root, check out RootTools. Then you can do:

    if (RootTools.isAccessGiven()) {
        CommandCapture command = new CommandCapture(0, "pm install " + PATH_TO_APK);
        RootTools.getShell(true).add(command).waitForFinish();
    }
    

    Note that waitForFinish() is a blocking call!

提交回复
热议问题