2013-09-28 2 views
1

나는이 코드를 가지고 다른 클래스에서이 코드TextView의 내용을 에코 처리 하시겠습니까?

public boolean busybox() throws IOException 
{ 

     try 
     { 

     Process p =Runtime.getRuntime().exec("busybox"); 
     InputStream a = p.getInputStream(); 
     InputStreamReader read = new InputStreamReader(a); 
     BufferedReader in = new BufferedReader(read); 
     StringBuilder buffer = new StringBuilder(); 

     String line = null; 

     try { 

      while ((line = in.readLine()) != null) { 
       buffer.append(line); 
      } 

     } finally { 
      read.close(); 
      in.close(); 
     } 

     String result = buffer.toString().substring(0, 15); 
     System.out.println(result); 

     return true; 
     } catch (Exception e) { 
     e.printStackTrace(); 
    } 

     return false; 
     } 

와 클래스가

try { 
    if(root.busybox()) { 

     Busybox.setText(Html.fromHtml((getString(R.string.busybox)))); 


    } 
    else { 

     Busybox.setText(Html.fromHtml((getString(R.string.no)))); 

    } 
} catch (IOException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 
      } 
     }); 

나는이 텍스트 뷰에서 작성하려는 경우에서 System.out.println에 의해 생성 된 outpout (결과) ;

어떻게하면됩니까? 미리 감사드립니다! 여러 번 시도했지만 몇 가지 오류가 있으며 코드가 잘못되었습니다.

+0

가 어느 선이 예외가 발생 사용할 수 있습니까? 당신은 logcat을 게시 할 수 있습니까? – Szymon

답변

1

return result과 같은 문자열로 변경 반환 유형 public boolean busybox().

다음

try { 
String myResult=root.busybox(); 
if(myResult!=null&&myResult.length>0) { 

    Busybox.setText(Html.fromHtml((myResult))); 


} 
else { 

    Busybox.setText(Html.fromHtml((getString(R.string.no)))); 

    } 
} 
+0

그것은 작동합니다. 고마워. –

+0

언제나 환영합니다 !! –

관련 문제