How to keep a XMPP connection stable on Android with (a)smack?

后端 未结 6 1895
梦毁少年i
梦毁少年i 2020-12-02 18:39

I use asmack-android-7-beem library for Android. I have a background service running, such as my app stays alive. But sooner or later XMPP connection dies without any notice

6条回答
  •  Happy的楠姐
    2020-12-02 19:31

    When using asmack put some code like this in your app to make Dalvik load the ReconnectionManager class and run it's static initialization block:

    static {
        try {
            Class.forName("org.jivesoftware.smack.ReconnectionManager");
        } catch (ClassNotFoundException ex) {
            // problem loading reconnection manager
        }
    }
    

提交回复
热议问题