Hello i have a homework to make a chat for fb,gmail,msn,yahoo and other clients..
I cant conect to chat and i can't understand why, if i run it with out my usename and usepassword is run but if i put it is not open the app...
I am thnkfull if anyone help me.
sorry for my bad enghlish
package com.example.chatonly; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import java.util.ArrayList; import java.util.List; import org.jivesoftware.smack.*; import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.util.StringUtils; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.widget.*; public class Chat extends Activity { private final static String SERVER_HOST = "talk.google.com"; private final static int SERVER_PORT = 5222; private final static String SERVICE_NAME = "gmail.com"; private final static String LOGIN = "xxxxxx@gmail.com"; private final static String PASSWORD = "xxxxxx"; private List<String> m_discussionThread; private ArrayAdapter<String> m_discussionThreadAdapter; private XMPPConnection m_connection; private Handler m_handler; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); m_handler = new Handler(); try { initConnection(); } catch (XMPPException e) { e.printStackTrace(); } final EditText recipient = (EditText) this.findViewById(R.id.recipient); final EditText message = (EditText) this.findViewById(R.id.message); ListView list = (ListView) this.findViewById(R.id.thread); m_discussionThread = new ArrayList<String>(); m_discussionThreadAdapter = new ArrayAdapter<String>(this, R.layout.multi_line_list_item, m_discussionThread); list.setAdapter(m_discussionThreadAdapter); Button send = (Button) this.findViewById(R.id.send); send.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String to = recipient.getText().toString(); String text = message.getText().toString(); Message msg = new Message(to, Message.Type.chat); msg.setBody(text); m_connection.sendPacket(msg); m_discussionThread.add("moi :"); m_discussionThread.add(text); m_discussionThreadAdapter.notifyDataSetChanged(); } }); } private void initConnection() throws XMPPException { //Initialisation de la connexion ConnectionConfiguration config = new ConnectionConfiguration(SERVER_HOST, SERVER_PORT, SERVICE_NAME); m_connection = new XMPPConnection(config); m_connection.connect(); m_connection.login(LOGIN, PASSWORD); Presence presence = new Presence(Presence.Type.available); m_connection.sendPacket(presence); //enregistrement de l'ιcouteur de messages PacketFilter filter = new MessageTypeFilter(Message.Type.chat); m_connection.addPacketListener(new PacketListener() { public void processPacket(Packet packet) { Message message = (Message) packet; if (message.getBody() != null) { String fromName = StringUtils.parseBareAddress(message .getFrom()); m_discussionThread.add(fromName + ":"); m_discussionThread.add(message.getBody()); m_handler.post(new Runnable() { public void run() { m_discussionThreadAdapter.notifyDataSetChanged(); } }); } } }, filter); } }