The BlackBerry Advertising Service allows you to easily integrate banner ads into your application. I’m going to put together a quick sample application to show you just how easy it is. First, I’ll start with a basic class that creates a screen and pushes it onto the display stack.
* A simple sample application that demonstrates the use of the banner class
* from the Advertisement SDK. A sample Application Placement ID is used to
* demonstrate the simplicity of the API.
final class AdSample extends UiApplication
* This is an Application ID (APID) that is used solely for demonstration
* purposes. For your application you will need to use the one that will be assigned to you after registration.
private static final int APID = 0;
public static void main(String args)
AdSample app = new AdSample();
DemonstrationScreen demoScreen = new DemonstrationScreen();
private class DemonstrationScreen extends MainScreen
//Ad code goes here
Now that we have our simple application it’s time to our banner advertisement. Let’s place a banner ad into the DemonstrationScreen screen using its constructor:
//Create a banner object by passing it the demo application placement ID and null since we don’t have any meta data to pass.
Banner bannerAd = new Banner(AdSample.APID, null);
//Sets the size of the banner ad that specified in the bannerSize integer value.
//Adds the banner ad to the screen
That’s it! All the networking and rendering functionality is handled by the banner class so all that you are required to do is place it.