Missing messages when I was in another activity in android app

I have implemented smack in my android code. It is working nice. But I have an issue with getting chat message when I am in another activity. Even if I enter the chat window I missed those message (while I was in another activity). Chat is working perfect when I am in the chat window with the second user.

I am using Smack version 4.1.0 alpha 6.
Please advice.

Are you using Openfire as a server?
Do you have two (or more) connections to the server with the same user?

If the answer to both of those is yes, you may want to look at setting route.all-resources or route.really-all-resources.

If both are left unset, or set to false, Openfire will send messages to the user to the most recently active session with a non-negative priority.

If route.really-all-resources = true Openfire will send message to all sessions with a non-negative priority.

If route.all-resources = true Openfire will send messages to all sessions that share the highest non-negative priority.

Yes, I am using openfire as serve and currently only one connection with single server .
The chat is working fine with iOS app. But the mentioned issue only with android app.

This is probably an issue with your chat applications architecture. Ideally you want to have the XMPP connection not bound to any activity at all but instead handled by a service.