install apk in background using busybox

柔情痞子 提交于 2019-12-12 08:01:50

问题


can i install apk in background using busybox on rooted device ???

i see something like that but it doesn't work

process install;
CommandCapture command = new CommandCapture(0, "chmod 777 /data/app");
RootTools.getShell(true).add(command).waitForFinish(); 
CommandCapture command2 = new CommandCapture(0, "chmod 777 /system/xbin/busybox");
RootTools.getShell(true).add(command2).waitForFinish();
install = Runtime.getRuntime().exec("/system/xbin/busybox install " + Environment.getExternalStorageDirectory() + "/Download/" + "xxx.apk /data/app/xxx.apk");

回答1:


If you run su -c pm install myapp.apk in a root shell, you should be able install in the background (note the 'pm') part. This has nothing to do with busybox, you can use any shell and you certainly don't need to change permission of /data/app.




回答2:


without using busybox

install = Runtime.getRuntime().exec("su");   
DataOutputStream os = new DataOutputStream(install.getOutputStream());  
os.writeBytes("pm install "+APKFile.apk+"\n");  
os.writeBytes("exit\n"); 
os.flush();
install.waitFor();



回答3:


It looks you use two paths for your busybox binary. First you chmod it in /system/xbin, but then you invoke it from system/bin. Ensure you use right path. And chmod 777 /data/app looks VERY BAD.



来源:https://stackoverflow.com/questions/12598687/install-apk-in-background-using-busybox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!