1
我想通過java運行這些shell命令,但沒有成功。代碼執行完美但.so文件不執行。當我在adb中使用這些命令時,所有的工作都是完美的。需要運行shell命令android
private void submit() {
System.out.println("doooooooooo");
try {
String[] commands = {"cd /data/data/com.dailydeals.usethisnow/lib",
"./libdeals.so" };
Process p = Runtime.getRuntime().exec("/system/bin/sh -");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
for (String tmpCmd : commands) {
os.writeBytes(tmpCmd+"\n");
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("doneooooooooo");
}
參考這篇文章它會幫助你http://stackoverflow.com/questions/6882248/solved-running-shell-commands-though-java-code-on-android – Aerrow 2012-04-23 08:06:57
你可以不會執行.so – zapl 2012-04-23 08:08:18