How to get correct cell id and location area code in Android?

How to get correct cell id and location area code in Android?



I have found so much code that fetches cell-id and location area code and I use the code below to fetch cell-id and location area code.


TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();

int cid = cellLocation.getCid();
int lac = cellLocation.getLac();



The problem is, when I use an airtel-sim card it works fine and give cell-id =4331 and loc =610. But when I use a relience-sim card then it give wrong result cell-id =11541 and loc=18823. How might I resolve this?





Hi,i use the code from the url sunil-android.blogspot.in/2013/01/… to fetch the location and it works fine for airtel but in case relience it does not work . as i know it means that location area code and cell id that i get in case of relience is incorrect. any help?
– User10001
Jul 23 '13 at 7:52






There are many application that show correct cell id but my code doesnot work for 3g simcard .
– User10001
Mar 17 '14 at 7:28





what is your result with your relience-sim by using cid = cellLocation.getCid() & 0xffff;?
– sschrass
Mar 23 '14 at 13:30



cid = cellLocation.getCid() & 0xffff;





cell-id = 11541
– User10001
Mar 25 '14 at 17:06




2 Answers
2



Solutions are highlighted in the following thread: Android: CellID not available on all carriers?



In short you need to mask the number you get from getCid() when in 3G network with 0xffff. Following is a snippet:


getCid()


0xffff


GsmCellLocation cellLocation = (GsmCellLocation)telm.getCellLocation();

new_cid = cellLocation.getCid() & 0xffff;
new_lac = cellLocation.getLac() & 0xffff;



Hope that helps





I have already try this.
– User10001
Mar 25 '14 at 17:05



Cell IDs and LAC ids are different based on networks, as you have mentioned that you are using two different SIMs of different networks so you will get different cell and lac ids these will not be same. Because cell id of one operator will be different than other network as two different towers are used of different networks and they have assigned accordingly both ids.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế