Display a list of contacts who have installed your application
Before you begin: Make sure that you
have completed the task,
Register your
application with the BlackBerry Messenger platform, and that the class
that displays the screen passes in a reference to the
BBMPlatformContext object associated with your
application.
Code sample: Displaying a list of contacts who have installed your application
The following code sample assumes that the class that displayed the MyBBMContactListScreen has passed a reference to the application's associated BBMPlatformContext object into the MyBBMContactListScreen constructor.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.service.*;
import net.rim.device.api.ui.container.*;
import java.util.*;
public class MyBBMContactListScreen extends MainScreen
{
public MyBBMContactListScreen(BBMPlatformContext platformContext)
{
ContactListService contactListService = platformContext.getContactListService();
BBMPlatformContactList contacts = contactListService.getContactList();
Enumeration contactsEnum = contacts.getAll();
while(contactsEnum.hasMoreElements())
{
BBMPlatform contact = (BBMPlatformContact)contactsEnum.nextElement();
add(new LabelField(contact.getDisplayName());
}
}
}
Previous topic: Code sample: Sending a file to a contact