Should I need two actitives to send messages between two phones?
<p>I'm on the task of implementing an application that sends strings between two phones. The client side opens the connection with the server after prompting the user for the Ip of the server. I use an EditText field and a button for this purpose. When the connection is established, I want a new EditText field and a button to show up and the user to be able to input strings and click on the button to send those strings to the server. The server will show the message on the screen. 
Should I create a different activity for each EdiText&amp;button? That would be 2 activities. In that case, how could I pass a socket the first activity would've opened to stablish the connection to the second activity?
Is it possible to do this in just one activity? Considering each activity has 1 layout associated I find it difficult to implement, I would have to hide some fields and show others depending on the stage the program is in.</p>

<p>Thanks</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_client);

    serverIp = (EditText) findViewById(R.id.server_ip);
    connectPhones = (Button) findViewById(R.id.connect_phones);
    connectPhones.setOnClickListener(connectListener);


}

private OnClickListener connectListener = new OnClickListener() {

    @Override
    public void onClick(View v) {
        if (!connected) {
            serverIpAddress = serverIp.getText().toString();
            if (!serverIpAddress.equals("")) {
                Thread cThread = new Thread(new ClientThread());
                cThread.start();
            }
        }
    }
};

public class ClientThread implements Runnable {

    public void run() {
        try {
            Log.d("ClientActivity", serverIpAddress);
            InetAddress serverAddr = InetAddress.getByName(serverIpAddress);
            Log.d("ClientActivity", "C: Connecting...");
            Socket socket = new Socket(serverAddr, ServerActivity.SERVERPORT);
            connected = true;
            while (connected) {
                try {
                    Log.d("ClientActivity", "C: Sending command.");
                    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket
                                .getOutputStream())), true);
                        // where you issue the commands
                        out.println("message");
                        Log.d("ClientActivity", "C: Sent.");
                } catch (Exception e) {
                    Log.e("ClientActivity", "S: Error", e);
                }
            }
            socket.close();
            Log.d("ClientActivity", "C: Closed.");
        } catch (Exception e) {
            Log.e("ClientActivity", "C: Error", e);
            connected = false;
        }
    }
}
}
</code></pre>
