views:

2370

answers:

3

How can i open a url from BlackBerry? in j2me i'm use: this.platformRequest("http://www.google.com");

How can i do on BB?

Thk!!!

+1  A: 

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.

Richard
Or worse, crash! (if you're using a TCP connection instead of a BES or BIS connection)
Anthony Rizk
+5  A: 
Browser.getDefaultSession().displayPage("http://www.google.com");

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

kozen
+1  A: 

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

BrowserSession bSession = Browser.getDefaultSession();
bSession.displayPage(url);
SWATI