/** * Sets a filter for all the incoming XMPP-Messages on the Receiver's JID (XMPP-Account ID). * Also creates a listener for the incoming messages and connects the listener to the * XMPPConnection alongside the set filter. * * @param receiverJID the JID (XMPP-Account ID of the receiver) to which the filter is to be * set. */ protected void setFilterOnReceiver(String receiverJID) { filter = new AndFilter(new PacketTypeFilter(Message.class), new ToContainsFilter( receiverJID)); listener = new PacketListener() { @Override public void processPacket(Packet packet) { if (packet instanceof Message) { final Message xmppMessage = (Message) packet; Thread msgProcessThread = new Thread() { public void run() { processIncomingMessage(xmppMessage); } }; msgProcessThread.setDaemon(true); msgProcessThread.start(); } } }; connection.addPacketListener(listener, filter); }