Android で次のリスナーを使用して、XMPP 接続が失われたかどうかを検出できます。
connection.addConnectionListener(new ConnectionListener() {
@Override
public void reconnectionSuccessful() {
// TODO Auto-generated method stub
System.out.println("ConnectionListener ==== >>>>> reconnectionSuccessful");
}
@Override
public void reconnectionFailed(Exception arg0) {
// TODO Auto-generated method stub
System.out.println("ConnectionListener ==== >>>>> reconnectionFailed >>> " + arg0.toString());
}
@Override
public void reconnectingIn(int arg0) {
// TODO Auto-generated method stub
System.out.println("ConnectionListener ==== >>>>> reconnectingIn >>> " + arg0);
}
@Override
public void connectionClosedOnError(Exception arg0) {
// TODO Auto-generated method stub
System.out.println("ConnectionListener ==== >>>>> connectionClosedOnError >>>" + arg0.toString());
}
@Override
public void connectionClosed() {
// TODO Auto-generated method stub
System.out.println("ConnectionListener ==== >>>>> connectionClosed");
}
});