Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

BrowserField Sample Code - Create your first BrowserField2 application

by BlackBerry Development Advisor (Retired) on ‎05-03-2010 11:51 AM - edited on ‎09-20-2010 04:56 PM by BlackBerry Development Advisor (13,053 Views)

 

BrowserField is a class added to version 5.0 of the BlackBerry Java Development Environment that can be used to easily embed web content in a native (Java) BlackBerry application.

 

This class is commonly known as BrowserField2 because the previous RenderingSession and BrowserContent APIs (prior to 5.0) were collectively known as BrowserField when used.

 

Creating your first BrowserField2 application involves the following three steps:

 

  1. Create a BrowserField object
  2. Add the BrowserField to the screen
  3. Request content

 

Here is the source code for a fully functional BlackBerry application that uses the BrowserField API to display the content of http://www.blackberry.com:

 

 

package samplecode;

import net.rim.device.api.ui.container.*;
import net.rim.device.api.browser.field2.*;
import net.rim.device.api.ui.*;

class MyBrowserField2Sample extends UiApplication
{
private MainScreen _screen;
private BrowserField _bf2;

MyBrowserField2Sample()
{
_bf2 = new BrowserField();

_screen = new MainScreen();
_screen.add(_bf2);
pushScreen(_screen);

_bf2.requestContent("http://www.blackberry.com");
}

public static void main(String[] args)
{
MyBrowserField2Sample app = new MyBrowserField2Sample();
app.enterEventDispatcher();
}
}

 

See the following learning resources for more information on the BrowserField API:

 

Users Online
Currently online: 26 members 1,283 guests
Please welcome our newest community members: