Vì vậy, tôi muốn có thể viết một ứng dụng có thể bật và hiển thị các tin nhắn logcat, dmesg và cũng có thể chạy các lệnh như 'ls' ' cat '' echo '' cd. 'Android Runtime.getRuntime(). Exec() để điều hướng qua các thư mục
Nếu tôi làm như sau:
nativeProc = Runtime.getRuntime().exec("ls\n");
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(nativeProc.getOutputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(nativeProc.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
full = full + "\n" + line;
}
tôi có thể đưa văn bản "đầy đủ" tới Lưu và xem thư mục gốc.
Tuy nhiên, đó là tất cả những gì tôi có thể làm. Hãy nói rằng tôi muốn tìm một thư mục, và thay đổi nó, tôi đang gặp rắc rối.
Vì vậy, nếu tôi làm điều này:
nativeProc = Runtime.getRuntime().exec("ls\n");
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(nativeProc.getOutputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(nativeProc.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
full = full + "\n" + line;
}
/* Code here to confirm the existing of a directory*/
nativeProc = Runtime.getRuntime().exec("cd tmp\n");
BufferedReader in2 = new BufferedReader(new InputStreamReader(nativeProc.getInputStream()));
line = null;
String test = "\nStart1:\n";
while ((line = in2.readLine()) != null) {
test = test + "\n" + line;
}
Tôi nhận được gì cho cả hai "đầy đủ" và "văn bản"
ý tưởng Bất kỳ?