title: Show an Alert Dialog when a server socket accept a connection
body: <p>I need to created a class that implements a server socket that wait a connection request from a client (in this case the web browser). After that I have accepted the connection, I want to show an alert dialog with two buttons to the user. So, at the moment, I have the class ready to use for the server socket, and a method that implement the Alert Dialog. How can i use the alert dialog method inside the server socket class for show the message with the two buttons? Here is the server class:</p>
  
  <p>UPDATE: i have added the code for create an Alert Dialog after that the server has accepted the connection</p>
  
  <pre><code>public class ServerThread extends AndroidApp2 implements Runnable { 
      public void run() {
      try{
          if ( SERVERIP != null){ 
              handler.post(new Runnable(){ 
                  @Override
                  public void run(){
                      serverStatus.setText("Listening on IP: " + ip_address_conversion + ":" + SERVERPORT);                           
                  }
              });
              serverSocket = new ServerSocket(SERVERPORT);
              while (true){
                  Socket client = serverSocket.accept();
                  handler.post(new Runnable(){
                      @Override
                      public void run(){
                          serverStatus.setText("Connected"); 
                      }
                  });
                  try{                            
                      AlertDialog.Builder connection_alert3 = new AlertDialog.Builder(this);
                              connection_alert3.setTitle("Connection Incoming");
                              connection_alert3.setMessage("bla bla boa");
                              connection_alert3.setCancelable(false);
                              connection_alert3.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
                                  public void onClick(DialogInterface dialog, int id) {
  
                                  }
                              });
                              connection_alert3.setNegativeButton("No", new DialogInterface.OnClickListener(){
                                  public void onClick(DialogInterface dialog, int id){
  
                                  }
                              });
                              AlertDialog alert = connection_alert3.create();
                              alert.show(); 
                  } catch (Exception e){
                      handler.post(new Runnable() {
                          @Override
                          public void run() {
                              serverStatus.setText("Oops. Connection interrupted. Please reconnect your phones."); 
                          }
                      });
                      e.printStackTrace();
                  }
              }
          }else{
              handler.post(new Runnable(){
                  @Override
                  public void run(){
                      serverStatus.setText("Couldn't detect internet connection.");   }
              });
          }
      }catch (Exception e) {
          handler.post(new Runnable(){
              @Override
              public void run(){
                  serverStatus.setText("Error");
              }
          });
          e.printStackTrace();
      }
    } 
  }
  </code></pre>
  
  <p>Thanks</p>