Install / Unistall from shell command in Android

后端 未结 6 1779
一生所求
一生所求 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条回答
  •  醉酒成梦
    2020-12-28 21:39

    Runtime.getRuntime().exec("pm install /mnt/sdcard/HelloAndroid.apk\n");

    This works for me, although two more additional details have to be done:

    1. Add android:sharedUserId="android.uid.system" in AndroidManifest.xml.

    2. Signed the apk with the system key.

      But in this way it seems there is no way to tell whether the installation is succeeded, so I will try @Ginger's method later.

提交回复
热议问题