title: key dispatching timed out
body: <p>I get a keydispatchingtimedout error, and can't seem to find the reason. Any help? 
  As you can see, I have created a server class that my android is supposed to connect to when started, which it does. But while trying to retrieve data, that is coming from my database mysql, it freezes.</p>
  
  <pre><code>import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.ObjectInputStream;
  import java.net.InetSocketAddress;
  import java.net.Socket;
  import java.util.ArrayList;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.Message;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  
  
  public class TutorialActivity extends Activity {
  
      private Socket socket;
      private ObjectInputStream dos;
      private DataInputStream dis;
  
  
      public void connect(){
          socket = new Socket();
          InetSocketAddress ipPort = new InetSocketAddress("192.168.0.10",4444);
          try{
              socket.connect(ipPort);
              dis = new DataInputStream(socket.getInputStream());
              dos = new ObjectInputStream(socket.getInputStream());
          }catch(Exception e){
              Log.d("OUT_CON",e.toString());
          }
  
          while (true) {
              try {
                  String msg = dis.readUTF();
                  if (msg.equals("Hej")) {
                      Thread.sleep(50);
                      receiveArrayList();
                  }
  
              } catch (Exception e) {
              }
          }
      }   
      /** Called when the activity is first created. */
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          final Button sButton = (Button) findViewById(R.id.sbutton);
          sButton.setOnClickListener(new View.OnClickListener(){
              @Override
              public void onClick(View v){            
              connect();
              }
          });
      }
  
      public void receiveArrayList() {
          try {
              FileInputStream fis = new FileInputStream("randomList");
              dos = new ObjectInputStream(fis);
              ArrayList a= (ArrayList) (dos.readObject());
              for(int i = 0; i &lt; a.size(); i++){
                  Log.d((String)a.get(i), null);
              }
  
              dis.close();
          } catch (ClassNotFoundException ex) {
              System.out.println(ex);
          } catch (IOException ex) {
              System.out.println(ex);
          }
      }
  }
  
  import java.io.DataOutputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.ObjectOutputStream;
  import java.net.*;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.ArrayList;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public class Server implements Runnable {
  
      private ServerSocket server;
      private Socket socket;
      private ObjectOutputStream oos = null;
  
      public Server() {
          try {
              server = new ServerSocket(4444);
              new Thread(this).start();
          } catch (Exception e) {
              System.out.println(e);
          }
      }
  
      public void run() {
          System.out.println("Server running");
          while (true) {
              try {
                  socket = server.accept();
                  sayHi();
              } catch (Exception e) {
              }
          }
      }
  
      private void sayHi(){
          DataOutputStream dos;
          try {
              dos = new DataOutputStream(socket.getOutputStream());
              oos = new ObjectOutputStream(socket.getOutputStream());
              dos.writeUTF("Hej");
              sendNames();
          } catch (IOException ex) {
              Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  
      public void sendNames() {
          final ArrayList&lt;String&gt; drinkar = new ArrayList&lt;String&gt;();
  
          Connection con = null;
          String url = "jdbc:mysql://localhost:3306/";
          String db = "drycker";
          String driver = "com.mysql.jdbc.Driver";
          String user = "root";
          String pass = "";
  
          try{
              Class.forName(driver).newInstance();
              con = DriverManager.getConnection(url+db, user, pass);
              try{
                  Statement st = (Statement) con.createStatement();
                  ResultSet res = st.executeQuery("SELECT * FROM  drinkar");
                  while (res.next()) {
                      String s = res.getString("Namn");
                      drinkar.add(s);
                  }
                  System.out.println(drinkar);
                  con.close();
              }
              catch (SQLException s){
                  System.out.println("SQL code does not execute.");
              }  
          }
          catch (Exception e){
              e.printStackTrace();
          }         
          ArrayList&lt;String&gt; a = new ArrayList&lt;String&gt;();
          a.add("Hejsan");
          a.add("Svejsan");
  
          try {
              FileOutputStream fos = new FileOutputStream("randomList");
              oos = new ObjectOutputStream(fos);
              oos.writeObject(drinkar);
              oos.flush();
              oos.reset();
              oos.close();
              fos.close();
          } catch (Exception e) {
          }
      }
  
      public static void main(String[] args) {
          new Server();
      }
  }
  </code></pre>