×
Namespaces

Variants
Actions
(Difference between revisions)

How to get cell information in Java ME using CBS

From Nokia Developer Wiki
Jump to: navigation, search
jimgilmour1 (Talk | contribs)
m (minor spelling and code format)
hamishwillee (Talk | contribs)
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Java ME]][[Category:Code Examples]][[Category:Java ME]]
+
[[Category:Java ME]][[Category:How To]][[Category:Code Snippet]][[Category:Telephony]]
 +
{{Abstract|This Java ME code snippet shows how to obtain cell information using the Cell Broadcast Service (CBS).}}
 +
 
 +
{{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= S60
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= MIDP 2.0
 +
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required (e.g. Location, NetworkServices.) -->
 +
|keywords= WMA, CBS, Cell info, PushRegistry, MessageConnection, TextMessage
 +
|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= 20090827
 +
|author= [[User:Im2amit]]
 +
}}
  
 
== Problem ==
 
== Problem ==
How to capture the Cell Info, which is displayed on the home screen of most of the GSM phones, if you set the Cell Info Display: ON in your phone settings. Cell info provides some (area)location related text info about the cell tower our device is present at the moment, along with some service providers advertisements. We don't have direct API in Java ME to capture this Cell Info from our application.
+
How to capture the cell information, which is displayed on the home screen of most of the GSM phones, if you set the Cell Info Display: ON in your phone settings. Cell info provides some (area)location related text info about the cell tower our device is present at the moment, along with some service providers advertisements. We don't have direct API in Java ME to capture this Cell Info from our application.
  
 
== Solution ==
 
== Solution ==
 
This Cell info is broadcasted as CBS (Cell Broadcast Service)  message by the cell towers and received by all the GSM phones connected to this tower on certain predefined Channel (generally 050) by most of the service providers. Thus our Java ME application can listen to this CBS Channel using Push Registry and capture this information
 
This Cell info is broadcasted as CBS (Cell Broadcast Service)  message by the cell towers and received by all the GSM phones connected to this tower on certain predefined Channel (generally 050) by most of the service providers. Thus our Java ME application can listen to this CBS Channel using Push Registry and capture this information
  
== Sample Codelets ==
+
== Sample Code ==
Register your Midlet for Listening to CBS port 50 and setup a MessageListener
+
=== Imports ===
 +
<Code>
 +
import javax.wireless.messaging.*;
 +
import javax.microedition.io.PushRegistry;
 +
</Code>
 +
 
 +
=== setupListening ===
 +
Register your Midlet for Listening to CBS port 50 and setup a Message Listener
 
<code java>
 
<code java>
 
public void setupListening()
 
public void setupListening()
Line 31: Line 63:
 
</code>
 
</code>
  
 
+
=== notifyIncomingMessage ===
 
To Retrieve the CBS message payload.
 
To Retrieve the CBS message payload.
 
<code java>
 
<code java>
Line 48: Line 80:
 
WMA 120/205 does not support CBS on most of the Nokia S40 devices, it works on Nokia S60 and other devices.
 
WMA 120/205 does not support CBS on most of the Nokia S40 devices, it works on Nokia S60 and other devices.
  
--Submitted by [http://discussion.forum.nokia.com/forum/member.php?u=353910 Amitabh Srivastava] at 16:10(IST), 27 August 2009.
+
The support for receiving CBS messages has been introduced in newer Series 40 5th Edition, Feature Pack 1 devices, all Series 40 5th Edition, Feature Pack 1 Lite devices and all Series 40 6th Edition devices.
 +
 
 +
--Submitted by [http://www.developer.nokia.com/Community/Discussion/member.php?353910-im2amit Amitabh Srivastava] at 16:10(IST), 27 August 2009.
 +
<!-- Translation --> [[pt:Como capturar informações do sistema celular]]

Revision as of 05:51, 14 February 2012

This Java ME code snippet shows how to obtain cell information using the Cell Broadcast Service (CBS).

Article Metadata
Tested with
Devices(s): S60
Compatibility
Platform(s): MIDP 2.0
Symbian
Article
Keywords: WMA, CBS, Cell info, PushRegistry, MessageConnection, TextMessage
Created: im2amit (27 Aug 2009)
Last edited: hamishwillee (14 Feb 2012)

Contents

Problem

How to capture the cell information, which is displayed on the home screen of most of the GSM phones, if you set the Cell Info Display: ON in your phone settings. Cell info provides some (area)location related text info about the cell tower our device is present at the moment, along with some service providers advertisements. We don't have direct API in Java ME to capture this Cell Info from our application.

Solution

This Cell info is broadcasted as CBS (Cell Broadcast Service) message by the cell towers and received by all the GSM phones connected to this tower on certain predefined Channel (generally 050) by most of the service providers. Thus our Java ME application can listen to this CBS Channel using Push Registry and capture this information

Sample Code

Imports

import javax.wireless.messaging.*;
import javax.microedition.io.PushRegistry;

setupListening

Register your Midlet for Listening to CBS port 50 and setup a Message Listener

public void setupListening()
{
try{
PushRegistry.registerConnection("cbs://:50",this.getClass().getName(),"*");
}catch(Exception e){}
String[] connList;
connList = PushRegistry.listConnections(true);
if((connList == null) || (connList.length == 0))
{
// You can exit the app, if you want
}
else
{
try{
msgconn = (MessageConnection)Connector.open("cbs://:50");
msgconn.setMessageListener(this);
} catch( IOException e){ e.printStackTrace();}
}
}

notifyIncomingMessage

To Retrieve the CBS message payload.

public void notifyIncomingMessage(MessageConnection conn)
{
try{
txtmsg =(TextMessage)msgconn.receive();
}catch(Exception e){System.out.println(e);}
from = txtmsg.getAddress());
Msg = txtmsg.getPayloadText();
// Display from & Msg
}

Note

WMA 120/205 does not support CBS on most of the Nokia S40 devices, it works on Nokia S60 and other devices.

The support for receiving CBS messages has been introduced in newer Series 40 5th Edition, Feature Pack 1 devices, all Series 40 5th Edition, Feature Pack 1 Lite devices and all Series 40 6th Edition devices.

--Submitted by Amitabh Srivastava at 16:10(IST), 27 August 2009.

143 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×