BlackBerry Development Fundamentals

What people have said about the book:

"What really amazed me about this book was that I learned quite a few things I never knew about the BlackBerry platform and I am not even a developer. Wargo does a brilliant job of explaining the whole infrastructure behind the BlackBerry ranging from BIS to BES to MDS to Push Services to all the different BlackBerry browsers."

Ronen Halevy
www.berryreview.com

 

Home Inside the Book Sample Code Chapter 11 - URL Launch Application
Chapter 11 - URL Launch Application PDF Print E-mail

Chapter 11 includes a sample BlackBerry Java application that highlights how to launch the default browser to a particular URL. Here's the code:

/*
 * urlLaunch.java
 *
 * This application launches a specific URL using the device's
 * default browser. Refer to BlackBerry Developer Knowledge 
 * Base article DB-00701 for information on how to launch a
 * particular browser.
 */

package com.bbdevfundamentals.urlLaunch;

import net.rim.blackberry.api.browser.Browser;
import net.rim.blackberry.api.browser.BrowserSession;
import net.rim.device.api.system.Application;

public class urlLaunch extends Application {

 // Put the URL you want launched here
 private static String appURL = "http://www.bbdevfundamentals.com";

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

 public urlLaunch() {
 // Get the default browser session
 BrowserSession browserSession = Browser.getDefaultSession();
 // Then display the page using the browser session
 browserSession.displayPage(appURL);
 // Once the URL is launched, close this application
 System.exit(0);
 }
}

This example was added to the book just to highlight one way to invoke the browser. In a real world application, you will want to launch a particular browser (the BlackBerry browser, Internet Browser, WAP Browser) depending on what your needs are for the application. RIM's knowledge base contains several articles on how to launch the browser including How to - Invoke the browser and How To - Create a web icon.

Attachments:
Download this file (URLLaunch.zip)URLLaunch.zip3 Kb26/10/09 09:13
 
InformIT (Pearson Education)