Troubleshooting guide

192
BlackBerry Java Development Environment Development Guide
Display content in a BlackBerry Browser field
To display web content in a BlackBerry® Browser field, use the net.rim.blackberry.api.browser package.
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();.
Define callback functionality for a
rendering session.
> Implement the RenderingApplication interface.
Retrieve a BlackBerry Browser field. 1. Invoke
RenderingSession.getBrowserContent(javax.microedition.io.HttpConnecti
on, net.rim.device.api.browser.field.RenderingApplication,
net.rim.device.api.browser.field.Event).
2. Store the returned object in a BrowserContent object. You render web content in the
BrowserContent
object.
BrowserContent browserContent =
_renderingSession.getBrowserContent(HttpConnection connection, this,
Event e);
Retrieve a field that renders the URL
content to your application for display.
>Invoke BrowserContent.getDisplayableContent(), storing the returned object in a
Field object.
Field field = browserContent.getDisplayableContent();
Display a BlackBerry Browser field. 1. To clear the current screen, invoke the MainScreen.deleteAll() method.
_mainScreen.deleteAll();
2. To add field data to the application screen, invoke MainScreen.add().
_mainScreen.add(field);
3. Create a non-main event thread to run BrowserContent.finishLoading()so that the UI
does not lock.
4. To render the new BlackBerry Browser content, invoke
BrowserContent.finishLoading().HTML files display a blank field until you invoke
BrowserContent.finishLoading()
. WML files and images might load before you invoke
this method.
Create a separate thread for rendering. > Create a non-main event thread that contains the instructions for retrieving and displaying the
BlackBerry Browser field.
class CreationThread extends Thread {
BrowserFieldHandlerApplication _callBackApplication;
BasicRenderingApplication _renderingApplication;
public CreationThread(BrowserFieldHandlerApplication
callBackApplication) {
_callBackApplication = callBackApplication;
}
public void run() {
_renderingApplication = new
BasicRenderingApplication(_callBackApplication);
BrowserField field =
_renderingApplication.getBrowserField("www.blackberry.com");
_callBackApplication.displayBrowserField(field);
}
}