我正在尝试以编程方式在Android-9设备上执行以下命令:
private void turnOnGpsCMD(){ String[] cmds = {"cd /system/bin" ,"settings put secure location_providers_allowed +gps"}; try { Process p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); for (String tmpCmd : cmds) { os.writeBytes(tmpCmd + "\n"); os.writeBytes("exit\n");