Question

I have used:

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cl = (GsmCellLocation) telephonyManager.getCellLocation();
int cid = cl.getCid();

This gives the long cell ID.

I'm using OpenCellID API to find latitude and longitude of my phone using cell ID, LAC (location area code), MNC (mobile network code) and MCC (mobile country code). Using long cell id gives inaccurate location while using short cell id give accurate location (almost). To test this, I found my phone's short cell id using this app.

But how to find the short cell ID using android API?

Was it helpful?

Solution

It appears that "short cell ID" is nothing but the lower 16 bits of the Long cell ID.

So I used:

int cid = cl.getCid();
short cid_short = (short) cid; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top