title: Receiving UDP packets in android
body: <p>I'm developing a P2P chat/sharing application for android. The following code is for receiving a UDP packet but only the first message/packet is received and displayed. (There's no problem in the sending code.) Subsequent chat messages are not displayed. The while loop seems to exit after chathistory.setText(new String.... is executed. eg:chathistory.setText("test"); is not executed. Can anyone point out the error? There is no exception thrown. </p>
  
  <pre><code>public void receive() throws Exception
          {
          (new Thread(new Runnable() {
  
          @Override
          public void run() {
              try 
              {
                  ds1=new DatagramSocket(7777);
                  //chathistory.setText("Holding the port...");
  
                  while(true)
                  {
  
                      DatagramPacket p = new DatagramPacket(buffer, buffer.length);
                      ds1.receive(p);
                      chathistory.setText(new String(p.getData(), 0, p.getLength()));
                      chathistory.setText("test");
  
                  }
              }
                      catch (Exception e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
          }   
  
          } })).start();
      }
  </code></pre>