I wonder how to confirm a request of adding friends.
Smack Version 4.1.1
As I know now ,
roster = Roster.getInstanceFor(con);
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
roster.createEntry(targetUser, nickname, new String[] {"friends"});
will create a roster in the database, and send a stanza request to the targetUser. And my stanza listener is as follows:
StanzaListener callback = new StanzaListener() {
        @Override
        public void processPacket(Stanza stanza) throws NotConnectedException {
            // TODO Auto-generated method stub
            String head = con.getUser() + " : ";
            System.out.println(head + "Got the presence stanza");
            if(((Presence)stanza).getType().equals(Presence.Type.subscribe)) {
                Presence subscribed = new Presence(Presence.Type.subscribed);
                subscribed.setTo(stanza.getFrom());
                System.out.println(head + subscribed.getFrom());
                subscribed.setFrom(stanza.getTo());
                con.sendStanza(subscribed);
                if( ! roster.contains(stanza.getFrom())) {
                    System.out.println(head + "Friend added.");
                    addFriend(stanza.getFrom(),"computer");
                }
            } else {
                System.out.println(head + "Subscribed received from " + stanza.getFrom());
                if(roster.contains(stanza.getFrom())) {
                    System.out.println(head + "OK");
                }
            }
        }
    };
It does not work, I wonder when the targetUser receives the stanza request , how to send a callback presence(or something else) to confirm or approve or agree? How to add a friend?
 
    