User Application에서 버튼을 클릭했을때 shell command 가 실행되도록 하고싶습니다.
 
"pwd", "ls", "cat"같은 shell command 또는 Native C로 제작한 console Application
실행되도록 하려면 어떻게 해야하나요? ㅠㅜ
 

[안드로이드 어플리케이션에서 외부 프로그램 수행] 
**********************************************************************************
 
......
import java.lang.Runtime;
import java.io.IOException;
.....
 
private void 해당버튼클릭(...) {
  try {
      pp = Runtime.getRuntime().exec("/system/bin/ls > /data/a.out");    /*  /data/a.out은
                                                                                                                         커멘드가 제대로 동작됬는지
                                                                                                                         확인하기 위해 넣었습니다       */
      pp.waitFor();
      exitVal = pp.exitValue();
      Log.i("tory","Exit value is:" + exitVal);   
  }
  catch(IOException e)
  {
      Log.i("IOException","Error on exec() method");
      return;
  }
  catch(InterruptedException e) {
      Log.e("InterruptedException",e.getLocalizedMessage(), e);
      return;
  }             
  finally {
      if (pp != null) {
            pp.destroy();
  } 
}
 
( 이 코드는 toto님의 코드를 참고하였습니다.
http://groups.google.com/group/android-developers/browse_thread/thread/c7be247ad3823712/0d5014f8fc119f49?show_docid=0d5014f8fc119f49 )
 
 
[fadden님의 답변글]***************************************************************
It's even simpler than that.  In system/extras/su/su.c:

    if (myuid != AID_ROOT && myuid != AID_SHELL) {
        fprintf(stderr,"su: uid %d not allowed to sun", myuid);
        return 1;
    }
 
So it should not work in the terminal application, but it should work from "adb shell".
**********************************************************************************
fadden님의 글을 보고 user application에서 shell command를 사용할 권한이 없기때문인가 싶어
플랫폼 전체 소스의 system/extras/su/su.c 파일에서 "return 1;" 부분을 주석처리해서 빌드해서 얻어낸
system.img, ramdisk.img, userdata.img로 에뮬레이터를 실행시켜보기도 했지만
여전히 "/data/a.out" 파일이 생성되지 않네요..ㅠㅜ
 
 
[안드로이드 어플리케이션에서 다른 안드로이드 어플리케이션 수행] 
**********************************************************************************
OnClickListener btnClick = new OnClickListener() {
    @Override
    public void onClick(View arg0) {
        String cmd = "CityListguide";
        String[] envp = {"com.google.android.citylistguide"};
         try {
            Log.i("Runtime", "cmd = " + cmd);
            Process ps = Runtime.getRuntime().exec(cmd, envp, new File("/data/app"));
            //Process ps = Runtime.getRuntime().exec(cmd);
            ps.waitFor();
            Log.i("Runtime", "CityListguide is exected.");
        }
        catch(Exception e) {
            Log.i("Runtime", "e.toString() = " + e.toString());
            e.printStackTrace();
        }
    }
}
**********************************************************************************
[
http://www.mail-archive.com/android-developers@googlegroups.com/msg00103.html]
 
제가 영어를 잘 해석한건지는 모르겠지만,
기존에 제작했던 안드로이드 어플리케이션은 이런 방법으로 하면
다른 안드로이드 어플리케이션 상에서도 수행이 가능하다는거 같았는데요
 
안드로이드 어플리케이션에서 버튼을 클릭했을때 shell command를 수행하게 하려면 어떻게 해야 하나요?
간단한 문제인데 제가 못해서 안되는건지,, 너무 답답합니다..ㅠㅜㅠㅜ
 
도움 부탁드려요..>_<