I am using asmack for an android IM application, where I am using remote service with AIDL interface.
Inside of onStartCommand
method of my service I write code as below. I create connection and then login using that. When anyone run my application inside onCreate
method of main activity of my application run my service getApplicationContext.StartService(serviceIntent)
. It's working fine, but after few minutes (sometimes 10 minutes and some time more than ten) messageListener
that I attach inside of service stops to receive messages. But I know that the connection exist, because same time I use xmppConnection
to send message it's sending message to user B but it not listening messages from user B. I don't know why my listener stop hearing message.
public int onStartCommand(final Intent intent, final int flags, final int startId) {
ConnectionConfiguration config = new ConnectionConfiguration(URL, MyPort, Host);
xmppConnection = new XMPPConnection(config);
xmppConnection.connect();
xmppConnection.login("someid@sample.com", "testpass");
xmppConnection.addPacketListener(myMessageListener, new PacketTypeFilter(Message.class));
return START_STICKY;
}
private PacketListener myMessageListener = new PacketListener() {
public void processPacket(Packet packet) {
Message msg = (Message) packet;
}
}
Please guide.