안녕하세요~!
adb shell 로 핸드폰 안으로 들어 가서 (핸드폰은 루팅이 되어 잇어요... 상관 없을 지 모르지만 혹시나 해서요 ,..)
process = Runtime.getRuntime().exec("chmod 777 /data/local/output.txt");
이런식으로 액티 비티 단에서 컨솔로 명령어를 넘겨 준다면
명령어의 결과로써 컨솔 내에서 출력 내용들이 아래와 같은데요...
chmod 777 /data/local/output.txt
이 문장을 그래도 안드로이드 액티비티 내의 textView에서 받아서 보여 줄 수 있을 까요?ㅠ_ㅜ
아래는 저의 코드와, 캡쳐한 사진들 입니다...
마동님 답변해 주셔서 감사해요! 아무튼... 어제 올린 질문 내용을 바탕으로 다시 코드를 짜 보았는데..
에러가 나요.. ㅠ_ㅜ
public class StartActivity extends Activity {
private Process process;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void start_onClick(View v) {
// TODO Auto-generated method stub
try {
process = Runtime.getRuntime().exec("chmod 777 /data/local/output.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
TextView show = (TextView)findViewById(R.id.content);
String str = new String();
str = br.readLine();
show.setText(str);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
디버그로 확인을 해 보니... str 값에 Null 값이 들어 옵니다... 아무래도 br 에서 아무 것도 읽어 들이지 못하는것 같아요 ㅠ-ㅜ
보시는 것과 같이.. 폰으로 들어가서 chmod 777 /data/local/output.txt 명령어를 치게 되면 ..
chmod 777 /data/local/output.txt 이렇게 응답이 나옵니다...
저는 이런식으로 chmod 777 /data/local/output.txt 와 같은 응답들을 textView로 보여 주고 싶은데...
ㅠ_ㅜ
답변 부탁드려요 !
(제하 핸드폰을 루팅을 해서 output.txt가 moutput.txt 처럼 보이는데... 이건 상관 없는것 같아요. 왜냐면 핸드폰 커널안에서
cat output.txt 같은 명령어는 잘 먹어요.. )
감사합니다!