Get CellId and other Imformation from mobile phones via J2ME

Without GPS or Network Operator we can still use the Location Based Service, via the help of CellId(Cell ID the location of Cell Identities of GSM-networks). Google has one enormous database of cell ids which are linked to a longitude and latitude position, that why Google Map client know where you are even you have no embedded GPS--it is not open. But there are other opened cellid DBs that we can use freely: opencellid , mobiforge.com and http://realtimeblog.free.fr/
Ok, one we can get the cell from phone we can query the location from these cellid DB. In GSM networks, all cells in the world have a globally unique ID made up of four numbers:
cell ID, LAC, MNC, and MCC.

For example, for Motorola:
Using JavaME to obtain Cell Positioning information

  1. {
  2. ….
  3. String cellid = System.getProperty("CellID");
  4. String lac = System.getProperty("LocAreaCode");
  5. String imsi = System.getProperty("IMSI");
  6. // Example IMSI (O2 UK): 234103530089555
  7. String mcc = imsi.substring(0,3); // 234 (UK)
  8. String mnc = imsi.substring(3,5); // 10 (O2)
  9. String location = mcc + mnc + lac + cellID; // A globally unique ID for a cell
  10. }

Information from Truly Mobile JavaME Applications: Location, Media Capture, and Connectivity

But get Cellid is still limited by mobile phone platform, Sign-certificate and Operator:

Nokia
s40 3rd Fp1 edition, requers operator or manufactureer signing
S60 3rd edition, FP2(released 2008 and newer, does not work on e.g. N95),no singing required

SonyEricsson:
Java platform 7.3 or higher (released around 2006 and newer)
older phone may need firmware update (7.1->7.3)
does not work in SE symbian (ie. UIQ) or windownsmobile(Xperia X1) phone
Information from Terminal-based Mobile Positioning overview

And notice, even you use the right code and sign your application, it is still not possible to query the cellID, because some telecom-operators have limited this service.

The fowllowing J2ME code could help you, J2ME Polish Syntax is used here to make the procedure easier. The functions here is not complete, because some manufactories have not released their J2ME API documents to query the cellID. If you have some information which is not included in the codes please let me and others know, please supplement here, thx!

  1. //#if polish.Vendor == BlackBerry
  2. //#= import net.rim.device.api.system.GPRSInfo;
  3. //#endif
  4.  
  5.  
  6. /**
  7. * get the cell id in the phone
  8. *
  9. * @return
  10. */
  11. public static String getCellId(){
  12. String out = "";
  13. try{
  14.  
  15. out = System.getProperty("Cell-ID");
  16. if(out== null || out.equals("null") || out.equals(""))
  17. out = System.getProperty("CellID");
  18. if(out== null ||out.equals("null")|| out.equals(""))
  19. System.getProperty("phone.cid");
  20. //#if polish.Vendor == Nokia
  21. if(out== null ||out.equals("null")|| out.equals(""))
  22. out = System.getProperty("com.nokia.mid.cellid");
  23. //#elif polish.Vendor == Sony-Ericsson
  24. if(out== null ||out.equals("null")|| out.equals(""))
  25. out = System.getProperty("com.sonyericsson.net.cellid");
  26. //#elif polish.Vendor == Motorola
  27. if(out== null ||out.equals("null")|| out.equals(""))
  28. out = System.getProperty("phone.cid");//System.getProperty("CellID");
  29. //#elif polish.Vendor == Samsung
  30. if(out== null ||out.equals("null")|| out.equals(""))
  31. out = System.getProperty("com.samsung.cellid");
  32. //#elif polish.Vendor == Siemens
  33. if(out== null ||out.equals("null")|| out.equals(""))
  34. out = System.getProperty("com.siemens.cellid");
  35. //#elif polish.Vendor == BlackBerry
  36. if(out== null ||out.equals("null")|| out.equals(""))
  37. //#= out = GPRSInfo.getCellInfo().getCellId();
  38. //#else
  39. if(out== null ||out.equals("null")|| out.equals(""))
  40. out = System.getProperty("cid");
  41. //#endif
  42.  
  43. }catch(Exception e){
  44. return out==null?"":out;
  45. }
  46.  
  47. return out==null?"":out;
  48. }
  49.  
  50. /**
  51. * get the lac sring from phone
  52. */
  53. public static String getLAC(){
  54. String out = "";
  55. try{
  56.  
  57. out = System.getProperty("phone.lac");
  58.  
  59. //#if polish.Vendor == Nokia
  60. if(out== null ||out.equals("null")|| out.equals(""))
  61. out = System.getProperty("com.nokia.mid.lac");
  62. //#elif polish.Vendor == Sony-Ericsson
  63. if(out== null ||out.equals("null")|| out.equals(""))
  64. out = System.getProperty("com.sonyericsson.net.lac");
  65. //#elif polish.Vendor == Motorola
  66. if(out== null ||out.equals("null")|| out.equals(""))
  67. out = System.getProperty("LocAreaCode");
  68. //#elif polish.Vendor == Samsung
  69. if(out== null ||out.equals("null")|| out.equals(""))
  70. out = System.getProperty("com.samsung.cellid");
  71. //#elif polish.Vendor == Siemens
  72. if(out== null ||out.equals("null")|| out.equals(""))
  73. out = System.getProperty("com.siemens.cellid");
  74. //#elif polish.Vendor == BlackBerry
  75. if(out== null ||out.equals("null")|| out.equals(""))
  76. //#= out = GPRSInfo.getCellInfo().getLAC();
  77. //#else
  78. if(out== null ||out.equals("null")|| out.equals(""))
  79. out = System.getProperty("cid");
  80. //#endif
  81.  
  82. }catch(Exception e){
  83. return out==null?"":out;
  84. }
  85.  
  86. return out==null?"":out;
  87. }
  88.  
  89. /**
  90. * Example IMSI (O2 UK): 234103530089555
  91. String mcc = imsi.substring(0,3); // 234 (UK)
  92. String mnc = imsi.substring(3,5); // 10 (O2)
  93. * @return
  94. */
  95. public static String getIMSI(){
  96. String out = "";
  97. try{
  98.  
  99. out = System.getProperty("IMSI");
  100. if(out== null ||out.equals("null")|| out.equals(""))
  101. out = System.getProperty("phone.imsi") ;
  102. //#if polish.Vendor == Nokia
  103. if(out== null ||out.equals("null")|| out.equals(""))
  104. out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
  105. if(out== null ||out.equals("null")|| out.equals(""))
  106. out = System.getProperty("com.nokia.mid.imsi");
  107. //#elif polish.Vendor == Sony-Ericsson
  108. /* if(out== null ||out.equals("null")|| out.equals(""))
  109. out = System.getProperty("com.sonyericsson.imsi");*/
  110. //#elif polish.Vendor == Motorola
  111. if(out== null ||out.equals("null")|| out.equals(""))
  112. out = System.getProperty("IMSI");
  113. //#elif polish.Vendor == Samsung
  114. /* if(out== null ||out.equals("null")|| out.equals(""))
  115. out = System.getProperty("com.samsung.imei");*/
  116. //#elif polish.Vendor == Siemens
  117. /* if(out== null ||out.equals("null")|| out.equals(""))
  118. out = System.getProperty("com.siemens.imei");*/
  119. //#elif polish.Vendor == BlackBerry
  120. if(out== null ||out.equals("null")|| out.equals(""))
  121. //#= out = GPRSInfo.getCellInfo().getBSIC();
  122. //#else
  123. if(out== null ||out.equals("null")|| out.equals(""))
  124. out = System.getProperty("imsi");
  125. //#endif
  126.  
  127. }catch(Exception e){
  128. return out==null?"":out;
  129. }
  130.  
  131. return out==null?"":out;
  132. }
  133.  
  134. /**
  135. *
  136. * For moto, Example IMSI (O2 UK): 234103530089555
  137. String mcc = imsi.substring(0,3); // 234 (UK)
  138. * @return
  139. */
  140. public static String getMCC(){
  141. String out = "";
  142. try{
  143.  
  144. if(out== null ||out.equals("null")|| out.equals(""))
  145. out = System.getProperty("phone.mcc") ;
  146. //#if polish.Vendor == Nokia
  147. if(out== null ||out.equals("null")|| out.equals(""))
  148. //out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
  149. //#elif polish.Vendor == Sony-Ericsson
  150. if(out== null ||out.equals("null")|| out.equals(""))
  151. out = System.getProperty("com.sonyericsson.net.mcc");
  152. //#elif polish.Vendor == Motorola
  153. if(out== null ||out.equals("null")|| out.equals("")){
  154. out = getIMSI().equals("")?"": getIMSI().substring(0,3);
  155. }
  156. //#elif polish.Vendor == Samsung
  157. /* if(out== null ||out.equals("null")|| out.equals(""))
  158. out = System.getProperty("com.samsung.imei");*/
  159. //#elif polish.Vendor == Siemens
  160. /* if(out== null ||out.equals("null")|| out.equals(""))
  161. out = System.getProperty("com.siemens.imei");*/
  162. //#elif polish.Vendor == BlackBerry
  163. if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
  164. //#= out = GPRSInfo.getCellInfo().getMCC();
  165. //#else
  166. if(out== null ||out.equals("null")|| out.equals(""))
  167. out = System.getProperty("mcc");
  168. //#endif
  169.  
  170. }catch(Exception e){
  171. return out==null?"":out;
  172. }
  173.  
  174. return out==null?"":out;
  175. }
  176.  
  177. /**
  178. *
  179. * For moto, Example IMSI (O2 UK): 234103530089555
  180. String mnc = imsi.substring(3,5); // 10 (O2)
  181. * @return
  182. */
  183. public static String getMNC(){
  184. String out = "";
  185. try{
  186.  
  187. if(out== null ||out.equals("null")|| out.equals(""))
  188. out = System.getProperty("phone.mnc") ;
  189. //#if polish.Vendor == Nokia
  190. if(out== null ||out.equals("null")|| out.equals(""))
  191. out = getIMSI().equals("")?"": getIMSI().substring(3,5);
  192. //#elif polish.Vendor == Sony-Ericsson
  193. if(out== null ||out.equals("null")|| out.equals(""))
  194. out = System.getProperty("com.sonyericsson.net.mnc");
  195. //#elif polish.Vendor == Motorola
  196. if(out== null ||out.equals("null")|| out.equals("")){
  197. out = getIMSI().equals("")?"": getIMSI().substring(3,5);
  198. }
  199. //#elif polish.Vendor == Samsung
  200. /* if(out== null ||out.equals("null")|| out.equals(""))
  201. out = System.getProperty("com.samsung.imei");*/
  202. //#elif polish.Vendor == Siemens
  203. /* if(out== null ||out.equals("null")|| out.equals(""))
  204. out = System.getProperty("com.siemens.imei");*/
  205. //#elif polish.Vendor == BlackBerry
  206. if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
  207. //#= out = GPRSInfo.getCellInfo().getMNC();
  208. //#else
  209. if(out== null ||out.equals("null")|| out.equals(""))
  210. out = System.getProperty("mnc");
  211. //#endif
  212.  
  213. }catch(Exception e){
  214. return out==null?"":out;
  215. }
  216.  
  217. return out==null?"":out;
  218. }
  219.  
  220. /**
  221. * not used now
  222. * get the IMEI (International Mobile Equipment Identity (IMEI)) in the phone
  223. *
  224. * @return
  225. */
  226. public static String getIMEI(){
  227. String out = "";
  228. try{
  229.  
  230. out = System.getProperty("com.imei");
  231. //#if polish.Vendor == Nokia
  232. if(out== null ||out.equals("null")|| out.equals(""))
  233. out = System.getProperty("phone.imei");
  234. if(out== null ||out.equals("null")|| out.equals(""))
  235. out = System.getProperty("com.nokia.IMEI");
  236. if(out== null ||out.equals("null")|| out.equals(""))
  237. out = System.getProperty("com.nokia.mid.imei");
  238. if(out== null ||out.equals("null")|| out.equals(""))
  239. out = System.getProperty("com.nokia.mid.imei");
  240. //#elif polish.Vendor == Sony-Ericsson
  241. if(out== null ||out.equals("null")|| out.equals(""))
  242. out = System.getProperty("com.sonyericsson.imei");
  243. //#elif polish.Vendor == Motorola
  244. if(out== null ||out.equals("null")|| out.equals(""))
  245. out = System.getProperty("IMEI");
  246. if(out== null ||out.equals("null")|| out.equals(""))
  247. out = System.getProperty("com.motorola.IMEI");
  248. //#elif polish.Vendor == Samsung
  249. if(out== null ||out.equals("null")|| out.equals(""))
  250. out = System.getProperty("com.samsung.imei");
  251. //#elif polish.Vendor == Siemens
  252. if(out== null ||out.equals("null")|| out.equals(""))
  253. out = System.getProperty("com.siemens.imei");
  254. //#else
  255. if(out== null ||out.equals("null")|| out.equals(""))
  256. out = System.getProperty("imei");
  257. //#endif
  258.  
  259. }catch(Exception e){
  260. return out==null?"":out;
  261. }
  262.  
  263. return out==null?"":out;
  264. }

Some J2ME applications are also available:
http://www.ottaky.com/midlets.php#netmon2
http://www.cellspotting.com/webpages/cellspotting.html

Ref:
http://en.wikipedia.org/wiki/GSM_localization
http://www.paxmodept.com/telesto/blogitem.htm?id=531
http://www.slideshare.net/jaakl/terminalbased-mobile-positioning-overview-presentation
http://www.ottaky.com/midlets.php#netmon2
http://www.cellspotting.com/webpages/cellspotting.html


Blog

Comments

Re: Get CellId and other Imformation from mobile phones via J2ME

Certainly Google has one enormous database of cell ids which are linked to a longitude and latitude position.

Re: Get CellId and other Imformation from mobile phones via J2ME

works fine...Thanks for sharing the information. That’s a awesome article you posted.

Re: Get CellId and other Imformation from mobile phones via J2ME

Hi
i want to implement gps coordinates with lat&long application in j2me .
and install blackberry.

Re: Get CellId and other Imformation from mobile phones via J2ME

Hi, guys! Can anyone help me? I have found this blog and the post seems interesting but I am not sure if it suits me. I am going to order a custom dissertation on mobile phones and security. Do you think the post is useful for it? Thanks in advance.

Re: Get CellId and other Imformation from mobile phones via J2ME

I appreciate how it is publicly accessible. A lot surely benefited from this entry which is comprehensive and content rich. Thanks for creating this one!

Re: Get CellId and other Imformation from mobile phones via J2ME

J2ME development has emerged as one of the most popular technologies. Mobile Application developers choose J2ME platform because it includes flexible user interface, robust security, and built-in network protocols and support for networked and offline applications that can be downloaded dynamically. A real advantage with J2ME development is that it enjoys widespread support across all platforms. The need of the hour to fulfill your requirements is to secure, reliable and professional services pertaining to J2ME application development. With the help of effective J2ME application development, one can get the advantages of easy user interface, easy application navigational functionality, better networking capabilities and improved security. For more information, visit at: cash 4 phones. Smiling

Re: Get CellId and other Imformation from mobile phones via J2ME

com.nokia.mid.networkid

eg. "01 (Vodafone I)"

Re: Get CellId and other Imformation from mobile phones via J2ME

s40 : System.getProperty("com.nokia.mid.mnc")
s60 : System.getProperty("com.nokia.mid.networkID")

Re: Get CellId and other Imformation from mobile phones via J2ME

Wow, thanks for the insightful post. I look forward to reading more from you.

Re: Get CellId and other Imformation from mobile phones via J2ME

I am new in J2ME, and i want to made a application which gets cellid, network name , service provider name, but i don't know how i will do? and it is possible on nokia s60 3rd devices like Nokia 3250, i have done this on symbian, it is possible in j2me?

Re: Get CellId and other Imformation from mobile phones via J2ME

Still i am not able to get all phones cellid and other info mainly on motorola em-30, and also some of notation
are not woked as to get cellid in samsung phone code is System.getProperty("Cell-ID"); not the one given in above code.

so please there isany notations or code which works correctly with the dvices.

With regards
Jitain Sharma

Re: Get CellId and other Imformation from mobile phones via J2ME

very useful info, I was looking for Information on mobile phones with J2ME

Re: Get CellId and other Imformation from mobile phones via J2ME

Samsung, I have not found so much information for the properties, bad official document. Sad

Re: Get CellId and other Imformation from mobile phones via J2ME

Excellent post, thank you very much for taking the time to share with those who are starting on the subject. Greetings

Re: Get CellId and other Imformation from mobile phones via J2ME

Hi leelight/Daniel,

thanks for this great information.

Is there a typo in the code related Samsung? You have used imei instead of imsi by mistake, or is not it possible to get imsi for Samsung?

Also, in Daniel's comment, could you please clarify the system properties for Samsung?

signal strength is also needed to get cellid information.

what I found is only for Nokia:

String signal = System.getProperty("com.nokia.mid.networksignal");

Thanks...

Re: Get CellId and other Imformation from mobile phones via J2ME

Daniel Drozdzewski wrote:
Dear leelight,

Great post - thanks a lot.
I have inherited JME codebase and Ihave found following properties that you don't check for, however I cannot guarantee how accurate those are.

Best regards,

Daniel


//All com.sonyericsson.net.* properties are hexadecimal
//MNC variants
com.sonyericsson.net.cmcc
com.sonyericsson.net.mcc
com.sonyericsson.net.cmnc
com.sonyericsson.net.mnc

com.sonyericsson.net.lac

com.sonyericsson.net.cellid
//----------------------------

// CellID property found in motorola phones using Siemens modems (could also work on other phones using Siemens modems)
Siemens.CID

//LAC
phone.lai

//MCC on some nokias
com.nokia.mid.countrycode

//Samsung
CELLID
LAC
MCC
MNC

Thank you! it is useful for all !! I can not guarantee my code also, it is not possible to test the code on all the devices.

Re: Be careful using IMSI-derived MCC and MNC for location!

thank you for this information. you are right. By the way, i think CellId is just the supplement for GPS, it's location is ALWAYS inaccurate :) Jawdropping!

Be careful using IMSI-derived MCC and MNC for location!

The IMSI contains the MCC and MNC for your home network, and does not change (its is effectively hard-coded into the SIM). If you roam to another network and/or country, the IMSI does not change.
With the code above, if you roam to another country, your location will be incorrect - you have a CellId which is dynamic and for the roaming network, but you will be adding the MCC/MNC from your home network! Result -> Incorrect location.

What you need is the current nework MCC and MNC (which is only the same as the MCC/MNC in the IMSI when you are in your home network)

Re: Get CellId and other Imformation from mobile phones via J2ME

This will be of great use for me. I appreciate how it is publicly accessible. A lot surely benefited from this entry which is comprehensive and content rich. Thanks for creating this one!

Re: Get CellId and other Imformation from mobile phones via J2ME

Dear leelight,

Great post - thanks a lot.
I have inherited JME codebase and Ihave found following properties that you don't check for, however I cannot guarantee how accurate those are.

Best regards,

Daniel


//All com.sonyericsson.net.* properties are hexadecimal
//MNC variants
com.sonyericsson.net.cmcc
com.sonyericsson.net.mcc
com.sonyericsson.net.cmnc
com.sonyericsson.net.mnc

com.sonyericsson.net.lac

com.sonyericsson.net.cellid
//----------------------------

// CellID property found in motorola phones using Siemens modems (could also work on other phones using Siemens modems)
Siemens.CID

//LAC
phone.lai

//MCC on some nokias
com.nokia.mid.countrycode

//Samsung
CELLID
LAC
MCC
MNC

Re: Get CellId and other Imformation from mobile phones via J2ME

Thanks!

Re: Get CellId and other Imformation from mobile phones via J2ME

Wow thanks for the nice tutorial man. I would say that I had never heard anything about Cellid before reading your post about it. But now I am highly interested in this function and I plan to read more about it. The J2me in the mobile phones is well known for me because I am a junior mobile application developer by myself. Thanks one more time and keep writing good stuff!

Sincerely,

Steve Turnton from mobile application development

S60 3rd edition, FP2 -- released 2008 and newer

yes, right.
S60 3rd edition, FP2 -- released 2008 and newer
means fp1 does not work, fp2, fp3 fp4 and later feature pack will work

Re: Get CellId and other Imformation from mobile phones via J2ME

Lac code is not returned in Nokia S60 Fp1

Re: Get CellId and other Imformation from mobile phones via J2ME

hi, maybe, there is some special jsr specifications from Vendor such as Nokia, you can get some special capabilities. But i am not sure, you need read through the documents from official website. Eye-wink

Re: Get CellId and other Imformation from mobile phones via J2ME

Smiling Hi,

Other than CellID, could it be possible to get other information such as signal stength from some GSM cell tower?

Thanks!

Re: Get CellId and other Imformation from mobile phones via J2ME

read this:
http://www.easywms.com/easywms/?q=en/node/3578

Re: Get CellId and other Imformation from mobile phones via J2ME

> s40 3rd Fp1 edition, requers operator or manufactureer signing
how can such a signing be obtained?

Re: Get CellId and other Imformation from mobile phones via J2ME

To edit out line numbers: there are editors such as kate on linux, or Notepad++ on Windows, that allow "rectangular" selections, so it's easy to get rid of the line numbers.

Re: Get CellId and other Imformation from mobile phones via J2ME

It would be ahndy if there was a button to copy the code to the clipboard.. Editing out line numbers is a painful and tedious task

Post new comment

Smileys
{:)}{;)}{:(}{:D}{}:)}{:P}{:O}{:?}{8)}{:jawdrop:}{:sick:}
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • You may quote other posts using [quote] tags.
  • Glossary terms will be automatically marked with links to their descriptions.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.