Channels ▼

Embedded Systems

Radios, Cell Phones, & Java

Source Code Accompanies This Article. Download It Now.

Configuring Presets Automatically

A useful function that radio applications can provide is the ability to automatically configure radio tuner presets. The reasons for doing so range from autosetting for user convenience in a given location, to a sophisticated marketing mechanism for promoting affiliated radio stations as listeners roam from state to state or country to country.

To begin with, the application needs to know how many preset channels are available on the mobile phone. This number varies from five to ten or more, and can be ascertained from TunerControl's getNumberOfPresets() method:

int NumberOfPresets = 

To preset a channel, you must have the radio station's various turning and interaction information. These data can be stored offline and locally on the phone, or obtained on-line/over-the-air via a wireless data network service, such as the General Packet Radio Service (GPRS).

Online Radio Station Database

For online query of the radio station's preset data, the radio application can prompt users for their geographical location via a text entry, or provide a list of likely locations. Better yet, the radio application can directly read the user's GPS coordinates via the JSR-179 Location API ( documents/s=9938/ddj0601i/0601i.html). Both of these approaches enable a database server to determine the location of listeners and return a list of radio stations with coverage in that area. In other words, this would be like "GSM roaming," except that it is "radio station roaming." The radio application will then replace and update the static (and most likely out-of-range) radio presets with radio station names and frequencies receivable and valid for the area that listeners are currently at.

For instance, assume users have just arrived at a new area where the available radio stations are:

  • KAAAA, an independent network operating at 97.0 MHz on the FM dial.
  • KBBBB, a KEEEE affiliate operating at 104.6 MHz FM.
  • KCCCC, a KFFFF affiliate broadcasting at 110.5 MHz FM.

If it was a purely utilitarian application, the radio application could simply update the preset in a sequential manner, using radio stations it encounters as it scans the spectrum from the lowest to the highest frequency. For example, if the tuner picks up the first station at 97.0 MHz and there is an entry for 97.0 MHz on the server's list, the application will set Preset 1 to 97.0 MHz with the corresponding radio station name indicated in the list ("KAAAA"), and so on.

If the radio application was sponsored or provided by a radio-station network, the server's database list could include only affiliated radio stations. Because the radio stations on 97.0 MHz and 104.6 MHz are not affiliates of the network "KFFFF," the sponsored application skips to the next station until it finds a station with a matching frequency that is an affiliate of the radio network. On the listener's phone, the preset eventually becomes Preset 1 at 110.5 MHz and the corresponding radio station name becomes "KCCCC."

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.