Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

(Redirected from C.B.S MESSAGE)

Recieving Cell Broadcasting Services (CBS) Messages on Java ME

From Wiki
Jump to: navigation, search
Article Metadata
Created: honest_success (29 Sep 2008)
Last edited: hamishwillee (24 Jul 2013)

C.B.S strands for Cell Broadcasting Services. Using J2ME we are able to receive C.B.S message but it is not possible to send C.B.S message. We can receive the C.B.S message which is being broadcast on particular channel. For the service provider like AIRTEL and Vodafone we can receive it on the channel 50. C.B.S message is also part of WMA API (Wireless Messaging API) in Java ME and works in same manner as SMS (Short Message Service) and MMS (Multimedia Messages). The significant difference is in SMS we are using port number to receive messages and for C.B.S we need to register for particular channel Number.

This feature is not supported by all Nokia devices. See here for details.

Process of Receiving C.B.S

1) Device Settings

It is advisable to make settings in device so device can also receive C.B.S. Perform the following steps.

  • Go to Message menu
  • Go to option and select C.B.S
  • Select subscribe and give channel number(50 for the service provider like Airtel and Hutch)

The above are the settings which i have done in E50 if you have other mobile then there might be some change.

2) Register for a particular channel

The first step we need to do is register for particular channel to receive the C.B.S from application.

this.connection = (MessageConnection)"cbs://:50", Connector.READ);

Use the following method of push registration to start the application at the time of receiving C.B.S.

Syntax:   registerConnection(String connection, String midlet, String filter)
Example: pushRegistery.registerConnection("cbs://:50",this,*);

Source Code:

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.Item;
import javax.wireless.messaging.MessageListener;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.Message;
import javax.wireless.messaging.TextMessage;
public final class CbsTestMIDlet extends MIDlet implements MessageListener, Runnable {
private MessageConnection connection;
private Form form;
private int count;
protected void startApp() throws MIDletStateChangeException {
Display display = Display.getDisplay(this);
form = new Form("CBS Test");
form.append(appendLine("Open channel..."));
try {
this.connection = (MessageConnection)"cbs://:50", Connector.READ);
} catch (Throwable t) {
display.setCurrent(new Alert("Error", t.toString(), null, AlertType.ERROR), form);
protected void pauseApp() {
protected void destroyApp(boolean b) throws MIDletStateChangeException {
// TODO quit politely
public void notifyIncomingMessage(MessageConnection messageConnection) {
if (++count > 24) { // 24 msgs max - stop listening...
try {
} catch (IOException e) {
// ignore
} else {
(new Thread(this)).start();
public void run() {
try {
Message message = connection.receive();
if (message instanceof TextMessage) {
form.append(appendLine("[" + ((TextMessage) message).getPayloadText() + "]"));
} else {
form.append(appendLine("[<binary msg>]"));
} catch (IOException e) {
form.append(appendLine("[" + e.toString() + "]"));
private Item appendLine(String line) {
StringItem item = new StringItem(null, line);
item.setLayout(Item.LAYOUT_2 | Item.LAYOUT_NEWLINE_AFTER);
return item;
This page was last modified on 24 July 2013, at 04:50.
63 page views in the last 30 days.