Using the BlackBerry Browser
Display content in the BlackBerry Browser
Display content in a BlackBerry Browser field
Code sample
Display content in the BlackBerry Browser
To display web content in the BlackBerry® Browser, use the
Task
Retrieve a BlackBerry® Browser session.
Retrieve a non-default BlackBerry® Browser session.
Request a web page.
Display content in a BlackBerry Browser field
To display web content in a BlackBerry® Browser field, use the
Task
Access a rendering session.
Steps
Retrieving the default session overrides any open sessions on the BlackBerry device.
>
Retrieve the default
Browser.getDefaultSession()
Browser.getSession()
>
Invoke
BrowserSession.displayPage(String url),
>
Invoke
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);
}
}
}
};
Steps
RenderingSession.getNewInstance().
1. Invoke
2. Store the returned rendering session handle in a
RenderingSession _renderingSession = RenderingSession.getNewInstance();.
net.rim.blackberry.api.browser
BrowserSession
object by invoking the static method
.
.
net.rim.blackberry.api.browser
RenderingSession
6
package.
specifying the
package.
object.