pass object stream use intent method
<p>how can I pass object stream (exmple: BufferedReader or DataOutputStream n etc) to other activity <strong>(from Client_layoutActivity.class to chat_wall.class )</strong> if i use <strong>intent method</strong> like this: </p>

<pre><code>        Intent i = new Intent(Client_layoutActivity.this, chat_wall.class);
        startActivity(i);
</code></pre>

<p>I made a chat application that consists of several pages. <strong>The first page is the login page</strong>. in the first page, client use socket to communicated with server. <strong>After login process is success than server will send "login success"</strong>. <strong>After that clien side will change layout from first page (login page) to second page (chat wall page)</strong>. <strong>I mean to use socket, BufferedReader and DataOuputstream method from first page (i assume  socket for login process is still connected so i can still used this socket to communicate in second page - chatting process)</strong>. So i want to pass object Socket, BufferedReader and DataOuputstream to second page to used this. i write my code bellow:</p>

<p><strong>PAGE 1 : for login purpose</strong></p>

<pre><code>public void login(){
    try {
    String name     = usrname.getText().toString(); // usrname is android object edit 
                                                       text 
    String pass     = password.getText().toString();// password is android   
                                                               object edit text 

    String sending  = "login."+name + "." + pass + "." +"\n";
     System.out.println("Sending Message: "+sending);

    Socket clientsock = new Socket("192.168.136.6", 28000);
    System.out.println("connect to the server...");

    BufferedReader in    = new BufferedReader(new  
    InputStreamReader(clientsock.getInputStream()));
    DataOutputStream out = new DataOutputStream(clientsock.getOutputStream());

    out.writeBytes(sending);    

    String line = in.readLine();

    if (line.contentEquals("login success")){
        Toast.makeText(this, "login success", Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "receive data from 
    server:"+clientsock.getInetAddress(), Toast.LENGTH_SHORT).show();
        Intent i = new Intent(Client_layoutActivity.this, chat_wall.class);
        startActivity(i); 

    } else {
        Toast.makeText(this, "Error ", Toast.LENGTH_SHORT).show();
    }


}
catch (Exception e)
{
    System.out.println(e);
    System.out.println("Connection Failed");
}
</code></pre>

<p><strong>PAGE 2 : for Chat purpose</strong></p>

<pre><code>package com.willis.layout;

import java.io.*;
import java.net.*;

import android.widget.*;
import android.os.Bundle;
import android.view.*;
import android.view.View.OnClickListener;
import android.app.Activity;
import android.R.integer;

 public class chat_wall extends Activity {

Client_layoutActivity ob;   
public EditText chatroom;    
   public Button sendbtn;

 public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.chatwall);       

  sendbtn = (Button)findViewById(R.id.sendmsg);
  sendbtn.setOnClickListener(new OnClickListener() {
      public void onClick(View view) {                  

              sendingmsg();                                         
          }
      });

 chatroom = (EditText)findViewById(R.id.chatroom);     

 }   

 public void sendingmsg (){    

   try
    {   


        BufferedReader in    = new BufferedReader(new 
            InputStreamReader(clientsock.getInputStream()));
        DataOutputStream out = new DataOutputStream(clientsock.getOutputStream());

    String name     = chatroom.getText().toString();            
    String send = "chat."+name+". \n";

        System.out.println("Sending message: "+send);
        out.writeBytes(send);

        String msgin = in.readLine();
        Toast.makeText(this, msgin, Toast.LENGTH_SHORT).show();

    }
    catch (Exception e)
    {
        System.out.println(e);
        System.out.println("Connection Failed");
    }
    }

     }
</code></pre>
