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?
A GSM Cell ID (CID) is a generally unique number used to identify each base transceiver station (BTS) or sector of a BTS within a location area code (LAC) if not within a GSM network.
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:
GsmCellLocation cellLocation = (GsmCellLocation)telm.getCellLocation();
new_cid = cellLocation.getCid() & 0xffff;
new_lac = cellLocation.getLac() & 0xffff;
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With