title: Nexus 7 Opening a Socket at android api lvl 16 and 17 gives crash?
body: <p>I have file sender code which works on api lvl 8 and 9. But when i changed the target-api lvl as 16 or 17 it gives error and program closes directly. When i remove &lt;"android:targetSdkVersion=.."> property it works. But i need to write that property as 16 or 17 lvl. I need to work 16 or 17 api lvls.
  (My nexus 7 version 4.2.2 (api lvl 17) and i will use some 16/17 api lvl properties for usb applications)</p>
  
  <p>Here is the working send file code: </p>
  
  <pre><code>SendButton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              try {
                      Socket sock = new Socket("192.168.2.7",5656); 
                      File myFile = new File ("/mnt/sdcard/TEST/TEST.xml");
                      byte [] mybytearray  = new byte [(int)myFile.length()];
                      FileInputStream fis = new FileInputStream(myFile);
                      BufferedInputStream bis = new BufferedInputStream(fis);
                      bis.read(mybytearray,0,mybytearray.length);
                      OutputStream os = sock.getOutputStream();
                      os.write(mybytearray,0,mybytearray.length);
                      os.flush();
                      sock.close();
                  }   
              catch (IOException e) {
              }   
          }
      });
  </code></pre>
  
  <p>Here is the my Android Manifest file versions and permissions:</p>
  
  <pre><code>    android:minSdkVersion="8"
      android:targetSdkVersion="8" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt;
  </code></pre>
  
  <p>Code works like that. But i need to change android:targetSdkVersion="16 or 17". </p>
  
  <p>Any idea solution about that problem and how can i fix it for my Nexus7 ?</p>