Search code examples
androidgpscellid

Android: CellID not available on all carriers?


When I request the Cell ID and LAC information, on some devices I cannot retreive them.

I use this code:

TelephonyManager tm =(TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
location = (GsmCellLocation) tm.getCellLocation();

cellID = location.getCid();

lac = location.getLac();
  1. Does anyone know why some GSM carriers do not provide them?
  2. Do I need permissions for that?
  3. What else is there to know about retreiving the CellID and LAC?

Solution

  • So you can try something like. I have got cell id and the location area code for GSM. But for UMTS, getCid () returns a big number for exple 33 166 248. So i add modulo operator (exple xXx.getCid() % 0xffff).

    GsmCellLocation cellLocation = (GsmCellLocation)telm.getCellLocation();
    
        new_cid = cellLocation.getCid() % 0xffff;
        new_lac = cellLocation.getLac() % 0xffff;