2011-01-30 3 views
3

한 수퍼 유저 명령 안드로이드보다이 :더 내가 실행 트링있어

슬프게도
  String[] hin1 = { "su", "-c", 
        "mount -o remount,rw -t yaffs2 /dev/block/mtdblk3 /system" }; 
      try { 
       Runtime.getRuntime().exec(hin1); 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

      String[] hin2 = { "su", "-c", "m /system/etc/hosts" }; 
      try { 
       Runtime.getRuntime().exec(hin2); 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

      String[] hin = { "su", "-c", 
        "cp /sdcard/hosts /system/etc/" }; 
      try { 
       Runtime.getRuntime().exec(hin); 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

나는 모든 행동에 대한 새로운 버튼을 때만 작동하고 .. :(

는 방법이 있나요 한 번에 할 수있는 쉘보다 일반적인 린에이 하듯이 접근하는 것을 시작 않다면, su 명령, 즉 (구현 방식에 따라

감사

+0

다음과 같은 질문에서 살펴 본다보십시오 http://stackoverflow.com/questions/4905743/android-how-to-gain-root-in-an-anroid-application – Muzikant

답변

0

을 ?? 개 이상의 명령을 실행 ux)를 사용하면 여러 명령을 세미콜론으로 구분하여 하나의 문자열로 결합 할 수 있습니다.

또한 여러 명령을 포함하는 셸 스크립트를 만들 수 있으며 su를 사용하여 실행 파일을 실행 파일 위치에 넣어야 할 수도 있습니다.

+0

여러 명령을 포함하는 쉘 스크립트를 만들 수도 있고 su를 사용하여 실행 파일을 실행할 수도 있습니다. 취업 : - * – Paul

0

다음 명령이 시작되기 전에 하나의 명령을 끝내지 않을 것입니다. 간부 후 WAITFOR를 추가하십시오 :

Runtime.getRuntime().exec(hin1).waitFor(); 
1
의 작업도, 나는 다음과 같은 코드를 시도 그렇게 생각하지 마십시오

: 명령 스와 -c chmod를 777 dev에/TEST1에 대한

public class GainrootActivity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 


    } 

    public void gainroot(View view) 
    { 
     String[] hin1 = { "su", "-c","chmod 777 dev/test1" }; 
     try { 
       Runtime.getRuntime().exec(hin1); 
      } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
     } 

    } 
} 

전용 버튼 (dev 디렉토리에서 하나의 로그 파일의 권한을 변경하기 위해)하지만 작동하지 않았습니다. 이 부분에서 잘못된 점이 있습니다. 누락 된 점을 지적 할 수 있습니까? I에도뿐만 아니라의 AndroidManifest.xml에

<uses-permission android:name="android.permission.ACCESS_SUPERUSER" /> 

RGDS, Saurabh을이 줄을 넣어

관련 문제