11

How can I open a URL from BlackBerry ? in J2ME I am using:

this.platformRequest("http://www.google.com");

How can I do this on BlackBerry?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
  • The solution: http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800440/How_To_-_Create_a_web_icon.html?nodeid=1487655&vernum=0 Thk!!! –  Mar 05 '09 at 14:40

4 Answers4

17

If you want to launch a browser session you would use:

Browser.getDefaultSession().displayPage("http://www.google.com");

If you want to open, and then read the returned data for processing yourself:


HttpConnection google = (HttpConnection)javax.microedition.io.Connector.open("http://www.google.com");
int rc = google.getResponceCode();
...
InputStream is = google.openInputStream();

You do need to make sure that processing the connection and returned data does not happen on the event thread or your blackberry will hang.

BBdev
  • 4,898
  • 2
  • 31
  • 45
Richard
  • 8,920
  • 2
  • 18
  • 24
15
Browser.getDefaultSession().displayPage("http://www.google.com");

is the correct way to launch the BlackBerry browser with your URL.

kozen
  • 509
  • 3
  • 5
5

well i think kozen is right but u can go ahead like this,may be......

BrowserSession bSession = Browser.getDefaultSession();
bSession.displayPage(url);
Swati
  • 2,870
  • 7
  • 45
  • 87
1
BrowserSession myBrowser = Browser.getDefaultSession();
myBrowser.displayPage("http://www.stackoverflow.com");

or

Browser.getDefaultSession().displayPage("http://www.stackoverflow.com");
Jorgesys
  • 124,308
  • 23
  • 334
  • 268