How to get cell information in Java ME using CBS
This Java ME code snippet shows how to obtain cell information using the Cell Broadcast Service (CBS).
Article Metadata
Tested with
Compatibility
Article
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.
Note
WMA 120/205 does not support CBS on most of the Nokia Series 40 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.


16 Sep
2009
This article is good for understanding pushregistry class which is used for maintaining inbound connections.
This article is used for obtaining brodcasted cell information and it will be helpfull to every one.So where ever you are, your cell information like Cell tower information is easily gotton through this code.
Easy to Learn....
Abu Samra - Cell Info is not Pop-up on the screen
I think there is some issue with dislpaying the Cell Info message (channel 50) on the screen of NOKIA phones. I'm working on a Cell Broadcast system. I noticed the message is not displayed on the screen; it is just received in the inbox. while this is not the case with other vendors which display the message on the screen. I used NOKIA E71. E72, E75 & N96.
Can I ask why and how to receive it on the screen. I enable all the Cell Info Configuration of the handset.Abu Samra 09:56, 20 December 2011 (EET)
Hamishwillee - Sounds like a defect
Thanks for the report - we're investigating. It may take a little while before there is an update.
Regards
Hamishhamishwillee 02:32, 22 December 2011 (EET)
Skalogir - Alternative Solution with Reverse Geocoding
Hi Abu,
If I understand correctly you are trying to get some textual information on your current location from the Cell Info message. This approach might have some disadvantages especially if you attempt to create and distribute your application in countries where operators do no longer broadcast Cell Info messages. A better approach would be to retrieve the device's coordinates by using the Location API (JSR-179) and reverse geocode the coordinates by using the Nokia Maps API for Java ME. This (depending on the location) can give you detailed information about your current location, such as street name and number, post code and country.
You can find more information on how to use the Location API from the Developer's Library here: http://library.developer.nokia.com/topic/Java_Developers_Library/GUID-8610DF6B-1A97-4B53-B7C5-5EB6441CDEE5.html
There is also an article on how to retrieve your current location here: Best practises for listening to location updates with Java ME
As soon as you have retrieved your coordinates, all you have to do is reverse geocode them based on information from this article here: Reverse Geocoding an address from Geo-location with Maps API for Java ME
The latter uses the Nokia Maps API for Java ME, which can be downloaded from here:
http://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/skalogir 10:37, 16 March 2012 (EET)