Creating menu items for linked contacts

You can create menu items that are available in the Contacts application on the BlackBerry® device when a user views a contact that is linked with a contact in your application by invoking LinkedContactUtilities.registerMenuItems(). You must assign menu items to an application group by using the LinkedContactConstants interface.

Application group

Description

COMPOSE_SN_MENU_GROUP

social networking applications

COMPOSE_IM_MENU_GROUP

instant messaging applications

COMPOSE_OTHER_MENU_GROUP

applications that are not social networking applications or instant messaging applications

If a contact in the Contacts application is linked with contacts in multiple third-party applications, the menu items in the Contacts application are grouped with other applications of the same group.

  • Social networking menu items are grouped under the Social Networking menu item.
  • Instant messaging menu items are grouped under the Instant Messaging menu item.
  • Menu items from other types of applications are grouped under the Contact Using menu item.

The menu items from the third-party applications with linked contacts are integrated with the menu for the Contacts application.

Situation

Result

A group contains one application with linked contacts. The application contains one menu item.

The menu item for the application appears in the menu in the Contacts application.

A group contains one application with linked contacts. The application contains multiple menu items.

The application's name appears in the menu. Selecting the name displays a dialog box that contains a button for each menu item.

A group contains multiple applications with linked contacts.

The group menu item (such as Social Networking) appears in the menu. Selecting the group menu item displays a dialog box with a button for each application with linked contacts in the group.

Create menu items for linked contacts

You can create menu items that are available in the Contacts application on the BlackBerry® device when a user views a contact that is linked with a contact in your application.

  1. Import the required classes and interfaces.
    import net.rim.blackberry.api.menuitem.ApplicationMenuItem;
    import net.rim.blackberry.api.pdap.contactlinking.LinkedContactConstants;
    import net.rim.blackberry.api.pdap.contactlinking.LinkedContactUtilities;
    import net.rim.device.api.system.ApplicationDescriptor;
  2. Create a class that extends the ApplicationMenuItem class.
    public class LinkedMenuItem extends ApplicationMenuItem {...}
  3. Create an application descriptor for your application.
    ApplicationDescriptor appdesc = new
        ApplicationDescriptor(ApplicationDescriptor.currentApplicationDescriptor(), 
        "Linking Application", null);
    
  4. Create a variable to store the unique ID of your application.
    public static final long APPLICATION_ID = 0x1eredfe71d34760fdL;
  5. Create an array with one or more menu item instances.
    ApplicationMenuItem[] items = new ApplicationMenuItem[1];
    items[0] = new LinkedMenuItem();
  6. Invoke LinkedContactUtilities.registerMenuItems() to add the menu items for the linked contact to the menu. Pass in the array of menu items, the unique ID of your application, the application group, and the application descriptor.
    LinkedContactUtilities.registerMenuItems(items, APPLICATION_ID, 
        LinkedContactConstants.COMPOSE_SN_MENU_GROUP, appdesc);
    

Code sample: Creating menu items for linked contacts

To see an example of creating menu items for linked contacts, see the SampleMenuItem class and main() in the Contact Linking Demo sample application that is included in the BlackBerry® Java® SDK.

Previous topic: Remove a link

Was this information helpful? Send us your comments.