Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get same xmpp connection from one activity to another?
    text
    copied!<p>i am new programmer.i would like to implement sample application for getting chat by using xmpp server.In this implementation i have created connection by using ConnectionConfiguration object as follows :</p> <pre><code>ConnectionConfiguration connConfig =new ConnectionConfiguration(host, Integer.parseInt(sport), service); </code></pre> <p>I am passing connConfig object to XMPPConnection class by calling connect method i am getting connection and by calling login method passing with user name pand password then i am login to password.to login i am using a button.When i clicked on button i am using Intent for change the activity.One i am changing activity i would like to get the same connection in another activity.</p> <p>I have written code for <strong>LoginActivity</strong> as follows:</p> <pre><code> public class LoginActivity extends Activity { ConnectionConfiguration connConfig ; XMPPConnection connection; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.setting); ((Button)findViewById(R.id.login)).setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { connConfig =new ConnectionConfiguration(host, Integer.parseInt(sport), service); connection = new XMPPConnection(connConfig); connection.connect(); connection.login(uname, password); } }); } } </code></pre> <p>I have written <strong>ChatPageActivity</strong> as follows:</p> <pre><code> public class ChatPage extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.chatpage); //How to get the same XMPPConnection from LoginActivity here } } </code></pre> <p>how to get the same connection from LoginActivity to ChatPageActivity?</p> <p>please any body help me</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload