title: Unfortunately Application has stopped in android
body: <pre><code>import java.io.IOException;
  import java.io.PrintWriter;
  import java.net.Socket;
  import java.net.UnknownHostException;
  
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class MainActivity extends Activity {
  
       private Socket client;
       private PrintWriter printwriter;
       private EditText etMsg, etIP, etPort;
       private Button button;
       private String messsage;
       int port=0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          etIP=(EditText)findViewById(R.id.editText1);
          etPort=(EditText)findViewById(R.id.editText2);
          etMsg=(EditText)findViewById(R.id.editText3);
          button=(Button)findViewById(R.id.button1);
          button.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  messsage=etMsg.getText().toString();
                  etMsg.setText("");
                  port=Integer.parseInt(etPort.getText().toString());
  
                  try
                  {
                      client=new Socket(etIP.getText().toString(), port);
                      printwriter= new PrintWriter(client.getOutputStream(),true);
                      printwriter.write(messsage);
                      printwriter.flush();
                      printwriter.close();
                      client.close();
                  }
  
                  catch(UnknownHostException e)
                  {
                      e.printStackTrace();
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
  
  
              }
          });
      }
  
  
  }
  </code></pre>
  
  <p>Above is my code for socket programming. I have developed it in 2.2 froyo. It works fine on Android device and gives me proper output. But when I develope and run this code on latest version of Android such as IceCreamSandwhich and Jellybean, it shows me an error like Unfortunately Application has stopped. What is the problem, I am not getting it. Please help me to solve this. Manifest file is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.empty"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"&gt;&lt;/uses-permission&gt;
  
  
      &lt;uses-sdk
          android:minSdkVersion="14"
          android:targetSdkVersion="14" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.empty.MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>