public void removeFriend(String username) { Roster roster = jc.getConnection().getRoster(); RosterEntry entry = roster.getEntry(username); try { jc.getConnection().getRoster().removeEntry(entry); } catch (SmackException.NotLoggedInException e) { e.printStackTrace(); } catch (SmackException.NoResponseException e) { e.printStackTrace(); } catch (XMPPException.XMPPErrorException e) { e.printStackTrace(); } catch (SmackException.NotConnectedException e) { e.printStackTrace(); } }
public void addFriend(String username, String nickname) { Roster roster = jc.getConnection().getRoster(); try { roster.createEntry(username, nickname, null); Log.i("AddFriend:", username); } catch (SmackException.NotLoggedInException e) { e.printStackTrace(); } catch (SmackException.NoResponseException e) { e.printStackTrace(); } catch (XMPPException.XMPPErrorException e) { e.printStackTrace(); } catch (SmackException.NotConnectedException e) { e.printStackTrace(); } }