6
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 a BlackBerry Browser field
To display web content in a BlackBerry® Browser field, use the
net.rim.blackberry.api.browser
package.
Display content in the BlackBerry Browser
Display content in a BlackBerry Browser field
Code sample
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);
}
}
}
};
Task
Steps
Access a rendering session.
1.
Invoke
RenderingSession.getNewInstance().
2. Store the returned rendering session handle in a
RenderingSession
object.
RenderingSession _renderingSession = RenderingSession.getNewInstance();.
Summary of Contents for JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Page 4: ......
Page 7: ......
Page 10: ...10 BlackBerry Device Applications Integration Guide...
Page 12: ...12 BlackBerry Device Applications Integration Guide...
Page 50: ...50 BlackBerry Device Applications Integration Guide...
Page 56: ...56 BlackBerry Device Applications Integration Guide...
Page 65: ......
Page 66: ...2008 Research In Motion Limited Published in Canada...