1. 直接使用Intent卸载
//android自带了一个安装程序---/system/app/PackageInstaller.apk. //大多数情况下,我们手机上安装应用都是通过这个apk来安装 Uri uri = Uri.fromParts("package", "com.example.demo", null); Intent intent = new Intent(Intent.ACTION_DELETE, uri); startActivity(intent);
2. 通过pm命令方式实现静默卸载
//pm命令可以通过adb在shell中执行,同样,我们可以通过代码来执行 public static String execCommand(String... command) { Process process = null; InputStream errIs = null; InputStream inIs = null; String result = ""; try { process = new ProcessBuilder().command(command).start(); ByteArrayOutputStream baos… Read More