0
在桌面Java應用程序中,我能夠重新啓動我的Java應用程序,其中一些腳本不需要進行編譯(例如,我們可以遠程添加一些額外的東西):Android - 如何重新啓動正在運行的應用程序,並且需要自行重新啓動?
桌面腳本: restartme.sh
#!/bin/bash
export DISPLAY=:0.0
pkill java
java -cp SystemV.jar Main.Boot 0x01 &
# on the fly add new stuffs depending on the situations..
iperf -s -p 65000 &
convert -size 800x600 xc:transparent -font Bookman-DemiItalic -pointsize 50 -draw "text 25,90 ' inactive.'" -channel RGBA -blur 0x6 -fill steelblue -stroke white -draw "text 10,90 ' inactive.'" -antialias /var/www/html/video/now.jpeg;
x11vnc -forever -passwd x1x &
桌面應用程序:
system("/var/tmp/restartme.sh &");
public static String system(String cmds) {
String value = "";
try {
String cmd[] = { "/bin/sh", "-c", cmds};
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null) {
value += line + "\n\r";
line = reader.readLine();
}
}
catch (IOException ioe) {
ioe.printStackTrace();
}
catch (InterruptedException ie) {
ie.printStackTrace();
}
return value;
}
如何重新啓動在Android中,像桌面? 我可以使用默認的BASH或其他默認的內置Android shell腳本嗎?或者還有一些其他方法可以執行一些未編譯的腳本來執行?