That really depends on your design. But sometimes the simplest and most naive way of using a static field is sufficient, especially if you make the deliberate design decission to only support at most one XMPP connection at a time. Then you would have someting like
private static AbstractXMPPConnection connection;
and if you support multiple connections, then you could use a static map
That sounds like a insufficient approach. I usually design a state machine for the connection management, that is feed with various events. The state machine then decides if it needs to act (e.g. restore connectivity). Event sources are e.g. CONNECTIVY_CHANGED listener for Android, and, of course, Smack’s own ConnectionListener.
I meant property of custom Android application class. Will static field in Android application class be better than defining in activity? I only need simple messaging functionalities!