Example - Accept Invitation

This example shows how to accept the friend invitation of another user.

String JOINED_SERVER = "https://joinedserver.geomobile.de:7012/friendfinder";
String JOINED_API_KEY = "5923078164";

/* CREATE CLIENT */
JOClient client = JOClient.createJoinedClient(JOINED_SERVER, JOINED_API_KEY);

/* LOGIN USER */
JOUser user = client.login("username", "password");

/* GET FRIENDS */
List<JOFriend> friends = friends = client.getFriends(user);

/* GET ALL INVITATION */
List<JOFriend> friendsToAccept = JOFriendFactory.instance().getFriendsToAccept(friends);

/* ACCEPT ALL INVITATIONS */
for (JOFriend friend : friendsToAccept)
{
  client.addFriend(user, friend);
}

If the acceptance process fails, the client throws an exception. All potential exceptions are documented in the Java API Documentation of the Joined API for Android and can be found here.

An example implementation of the example is part of the Joined API for Android project and can be found here.