×
Namespaces

Variants
Actions
(Difference between revisions)

Recieving Cell Broadcasting Services (CBS) Messages on Java ME

From Nokia Developer Wiki
Jump to: navigation, search
tanjaluodes (Talk | contribs)
m
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix ArticleMetaData and RevieweApproval)
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{ArticleMetaData <!-- v1.1 -->
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080929
 +
|author= [[User:Honest success]]
 +
}}
 +
 
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.
 
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.
  
Line 113: Line 137:
 
[[Category:Java ME]]
 
[[Category:Java ME]]
 
[[Category:Messaging]]
 
[[Category:Messaging]]
[[Category:Level-Advanced]]
 

Revision as of 07:22, 8 February 2012

Article Metadata
Article
Created: honest_success (29 Sep 2008)
Last edited: hamishwillee (08 Feb 2012)

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) Connector.open("cbs://:50", Connector.READ);
 
this.connection.setMessageListener(this);

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.io.Connector;
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;
import java.io.IOException;
 
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");
display.setCurrent(form);
form.append(appendLine("Open channel..."));
try {
this.connection = (MessageConnection) Connector.open("cbs://:50", Connector.READ);
this.connection.setMessageListener(this);
form.append(appendLine("Waiting..."));
} catch (Throwable t) {
form.append(appendLine(t.toString()));
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 {
this.connection.setMessageListener(null);
} 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;
}
}
132 page views in the last 30 days.
×