how to send keepalives in XMPP in Android app

view story

http://stackoverflow.com – i don't know how to implement a keepalive connection in android http://xmpp.org/extensions/xep-0304.html . I'm using a service with asmack in my app. After two hours the connection break. I use a reconnection function to keep alive but doesnt work public void reconnect(){ try{ connection = Koneksi.getInstance().getConnection(); }catch(NullPointerException e){ SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE); String username = pref.getString(PREF_USERNAME, null); String password = pref.getString(PREF_PASSWORD, null); (HowTos)