shell查看文件權(quán)限 如何讓Android系統(tǒng)或Android應(yīng)用執(zhí)行shell腳本?
如何讓Android系統(tǒng)或Android應(yīng)用執(zhí)行shell腳本?Android系統(tǒng)執(zhí)行shell腳本時(shí),需要確認(rèn)用戶(hù)有修改shell的權(quán)限,并使用process執(zhí)行指令,如下:public void
如何讓Android系統(tǒng)或Android應(yīng)用執(zhí)行shell腳本?
Android系統(tǒng)執(zhí)行shell腳本時(shí),需要確認(rèn)用戶(hù)有修改shell的權(quán)限,并使用process執(zhí)行指令,如下:
public void execshell(string CMD){ttry{//permission setting process P=運(yùn)行時(shí).getRuntime(). Exec(“Su”)//開(kāi)始執(zhí)行shell腳本//get output stream OutputStream OutputStream=p.getoutputstream()dataoutputstream dataoutputstream=new dataoutputstream(OutputStream)//將命令寫(xiě)入dataOutputStream.writeBytes數(shù)據(jù)輸出流(CMD)//提交命令數(shù)據(jù)輸出流.flush()//關(guān)閉流操作數(shù)據(jù)輸出流.close() outputStream.close文件()}catch(Throwable t){t.printStackTrace()}}