静默卸载系统软件和第三方软件
转载自:http://www.eoeandroid.com/thread-230767-1-16.html
一个个卸载软件,弹出卸载软件提示好麻烦,现在特作出下列方法,可以静默卸载 静默安装敬请期待。。。。 //下面3句是静默卸载系统软件命令 String busybox="mount -o remount rw /system"; String chmod="chmod 777 /system/app/HtcTwitter.apk"; uninstallapk="rm -r /system/app/HtcTwitter.apk"; //下面3句是静默卸载第三方软件命令 String busybox1="mount -o remount rw /data"; String chmod1="chmod 777 /data/app/com.yingyonghui.market-2.apk"; uninstallapk1="pm uninstall com.yingyonghui.market"; chmodApk(busybox1,chmod1); /* * 对要卸载的apk赋予权限 */ public void chmodApk(String busybox ,String chmod) { try { Process process = null; DataOutputStream os = null; process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(busybox); os.flush(); os.writeBytes(chmod); os.flush(); os.close(); } catch (Exception ex) { ex.printStackTrace(); } } /* * 卸载apk */ public void uninstallApk(String uninstallapk) { try { Process process = null; DataOutputStream os = null; process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(uninstallapk); os.flush(); os.close(); } catch (Exception ex) { ex.printStackTrace(); } } |