I have an app that开发者_如何学Go I'm developing and the main screen is supposed to have a simple embedded browser frame on it that displays a single remote webpage. Can anyone provide me with the necessary code or a reference that will help me figure it out?
It depends on what OS version you are going to support. Since OS 5.0 RIM adds a new package net.rim.device.api.browser.field2
which simplifies things a lot. For both old API (pre 5) and newer there is a sample apps in the BB SDK that demonstrates embedded browser usage.
On my PC sample apps are in the following dirs:
- C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\samples\com\rim\samples\device\browser\browserfield2demo - newer API
- C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\samples\com\rim\samples\device\browser\browserfielddemo - old API
Also note that the sample for old API actually fails to open an HttpConnection. It results in white screen being displayed instead of page content, so feel free to fix the sample code to append the URL with a proper suffix (;device=true
or ;interface=wifi
). I assume you already know how to open HttpConnection on BB using different transports.
Yes can you please try this.
BrowserSession browserSession = Browser.getDefaultSession();
browserSession.displayPage("http://www.google.co");
browserSession.showBrowser();
精彩评论