그래서 logcat 메시지 dmesg를 켜고 표시 할 수있는 응용 프로그램을 작성하고 'ls'와 같은 명령을 실행할 수 있기를 원합니다. cat ''echo ''cd '.Android Runtime.getRuntime(). 디렉토리를 탐색하는 exec()
다음 작업을 수행 할 경우
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;
}
나는 텍스트보기로 텍스트 "전체"를 넣고 루트 디렉토리를 볼 수 있습니다.
그러나 그게 내가 할 수있는 전부입니다. 디렉토리를 찾고 그것을 변경하려고 할 때 문제가 발생한다고 가정 해 보겠습니다.
내가 이렇게 그래서 경우 :
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;
}
내가 "풀"과 "텍스트"
모든 아이디어를 모두 아무것도 얻을 수 없다?