안녕하세요
인터넷을 돌아다니다 이런 소스를 봤어요.
public String executeShell(String shell) {
java.lang.Process p = null;
BufferedReader in = null;
String returnString = null;
try {
p = Runtime.getRuntime().exec(shell);
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while (returnString == null || returnString.contentEquals("")) {
returnString = in.readLine();
}
} catch (IOException e) {
Log.e("executeTop", "error in getting first line of top");
e.printStackTrace();
} finally {
try {
if(in!=null)
in.close();
if(p!=null)
p.destroy();
} catch (IOException e) {
Log.e("executeTop",
"error in closing and destroying top process");
e.printStackTrace();
}
}
return returnString;
}
이제 질문을 할게요 ㅎ
Log.d(TAG,""+ executeShell("top -n 1"));
하면 로그가 제대로 뜨는데요.
메모리 가져오는 부분에서는 출력이 안되는데요
명령은 Log.w(TAG,""+ cm.executeShell("procrank -p"));
이렇게 줬구요
로그캣에는 아래와 같이 뜨네요. 워낙 기초도 없고 개념도 없어서 어떻게 작업을해야 할지 잘모르겠어요 ㅠ
조금만 도와주세요 ㅜ
java.io.IOException:
Error running exec(). Command: [procrank, -p] Working Directory: null Environment: null




procrank 는 루팅한 폰이나 안드로이드 초기에 나왔던 몇몇 폰에서만 보일 겁니다.. 권한문제로 막혀있을 걸요...
sdk에서 제공하는 api를 가지고 접근해 보시는것이 나을것같네요..