BlackBerry
Skip Top Navigation
Developers Partners
North America [change region] Products Solutions Purchasing Support
Developers


Using the Options API

Exercise

Make use of the BlackBerry® Options framework to let the user customize a Hello World application.

Objective

  • Discover how to define and register an OptionsProvider that exposes application configuration data.

Setup

  1. Download the file
  2. In the IDE, open the options.jdw workspace
  3. Open the HelloWorld.java source file.
  4. Open the HelloWorldOptionsProvider.java source file.
  5. Open the HelloWorldProperties.java source file.

Tasks

  1. Observe that there are two projects defining GUI and background entry points. See the “Communicating with other applications” exercise for details on multiple entry points.
  2. Observe that the class HelloWorldProperties defines a record type with the properties greeting and greetingEmphasized. The class persists one instance of itself, defining the Hello World application's current configuration. See the “Storing persistent data” exercise for details on persistence.
  3. Observe that the HelloWorld constructor's behavior differs depending on the values of the HelloWorldProperties.
  4. In the class HelloWorldOptionsProvider, define suitable UI controls for the greeting and greetingEmphasized properties as member variables.
  5. In the populateMainScreen method, instantiate those controls with initial values read from _properties.
  6. In the save method, write the user's input back to _properties.
  7. When the background entry point of the HelloWorld application is triggered, create a HelloWorldOptionsProvider and register that instance with the device's options manager.

Check Your Work

Download the completed code

Review

In this exercise, you discovered the following things:

  • to define and register an OptionsProvider that exposes application / configuration data.


Additional Labs

Go to the next exercise in “Connecting to Email, Calendar and PIM Applications on BlackBerry”, Using the MenuItem API

Back to the Developer Lab Main Menu

 
Other Resources
 
     
 Home | Products | Solutions | Purchasing | Support | Developers | Worldwide | News | About Us | Contact Us | Site Map
 Legal | Copyright © 2008 Research In Motion Limited, unless otherwise noted.