2017-01-02 2 views
0

"netstat"명령과 "curl"명령의 exec()를 수행하는 프로그램이 있습니다. 이 프로그램은 안드로이드 6.0.1에서 잘 실행됩니다. 안드로이드 버전 4.4.2에서 프로그램은 netstat 명령을 전달하지만 오류가있는 curl 명령에 실패합니다.curl 명령의 실행 오류 - 작업 디렉토리가있는 IOException null - Android OS 관련 문제

java.io.IOException : exec()를 실행하는 중 오류가 발생했습니다. 명령 : [curl, www.google.fr] 작업 디렉토리 : null 환경 : null

나는 권한 문제가 있다고 생각했지만 모든 것이 잘 보였다. 어떤 도움이라도 대단히 감사 할 것입니다.

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     Log.i("Build ", "version " + String.valueOf(Build.VERSION.RELEASE)); 

     String cmd1 = "netstat -an"; 
     String cmd2 = "curl www.google.fr"; 
     Runtime runtime = Runtime.getRuntime(); 
     Process proc = null; 

     try { 
      proc = runtime.exec(cmd1); 
      proc = runtime.exec(cmd2); 
      proc.getOutputStream().close(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

    } 

} 

과 manifest.xml : 사실 컬의

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.bernard_zelmans.curl"> 

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.STORAGE" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity android:name=".MainActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

답변

0

은 4.4.1

에서 명령으로 사용할 수 없습니다