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?

有帮助吗?

解决方案

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; 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top