Troubleshooting guide
13
Using the BlackBerry Browser
Display content in the BlackBerry Browser
To display web content in the BlackBerry® Browser, use the net.rim.blackberry.api.browser package.
Display content in the BlackBerry Browser
Display content in a BlackBerry Browser field
Task Steps
Retrieve a BlackBerry Browser session. Retrieving the default session overrides any open sessions on the BlackBerry device.
> Retrieve the default BrowserSession object by invoking the static method
Browser.getDefaultSession().
Retrieve a non-default BlackBerry Browser session. >Invoke Browser.getSession().
Request a web page. >Invoke BrowserSession.displayPage(String url), specifying the
URL that contains the web content.
The following excerpt from the Restaurants.java sample
creates a menu item that displays a web page in the
BlackBerry Browser.
private MenuItem browserItem = new
MenuItem(_resources.getString(MENUITEM_BROWSER), 110, 12)
{
public void run() {
synchronized(store) {String websiteUrl =
websitefield.getText();
if (websiteUrl.length == 0) {
Dialog.alert(_resources.getString(ALERT_NO_WEBSITE));
} else {
BrowserSession visit = Browser.getDefaultSession();
visit.displayPage(websiteUrl);
}
}
}
};