Retrieving application menu items from a BlackBerry device

The net.rim.blackberry.api.bbm.platform.ui.MenuItemManager class provides methods that allow your application to retrieve the menu items that your application has added to a user's BlackBerry® device. The net.rim.blackberry.api.bbm.platform.ui.InvitationMenuItem class encapsulates a menu item's information, for example, ID, order, label, and message.

To retrieve individual menu items, invoke MenuItemManager.getMenuItem() and pass in the menu item ID. If no menu item exists, the method returns null. To retrieve all menu items, invoke MenuItemManager.getMenuItems(), which returns an array of InvitationMenuItem[] items.

// Retrieve all menu items

InvitationMenuItem[] menuItems = _menuItemMgr.getMenuItems();

// Display the menu items

myScreen.add(new LabelField("The existing menu items are:"));

for(int i = 0; i < menuItems.length; i++)
{
    myScreen.add(new LabelField(menuItems[i].getId() + ": " + menuItems[i].getLabel()));
}

if (menuItems.length = 0)
{
    myScreen.add(new LabelField("There are no menu items to display."));
}    

Was this information helpful? Send us your comments.