Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get LTE cell location in android?

Tags:

android

lte

I see that we have classes for CDMACellLocation and GSMCellLocation, but there is nothing specific for LTE. Can can I get the LTE cell location specific to my telephony service context? Thanks!

like image 218
user1985703 Avatar asked Apr 25 '13 21:04

user1985703


People also ask

How do I get cell tower information on my Android?

Network Cell Info Lite (for Android) This highly-rated free Android app uses crowdsourced 4G and 5G tower location data from Mozilla Location Services. Once you open the app, go to the "map" tab. You'll see nearby towers, and the app will draw a blue line to the tower you're connected to.

What is Cell Information android?

A CellInfo representing a GSM cell that provides identity and measurement info. CellInfoLte. A CellInfo representing an LTE cell that provides identity and measurement info. CellInfoNr. A CellInfo representing an 5G NR cell that provides identity and measurement info.


1 Answers

you could take info from LTE connection, with a specific cast on instances belonging to CellInfo's list.

MobileInfoRecognizer mobileInfoRecognizer = new MobileInfoRecognizer();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> cellInfos = tm.getAllCellInfo();
additional_info = mobileInfoRecognizer.getCellInfo(cellInfos.get(0));

In my application I noticed that you can take only the first element in your list; I show you my custom class:

public class MobileInfoRecognizer {
    public String getCellInfo(CellInfo cellInfo) {
            String additional_info;
            if (cellInfo instanceof CellInfoGsm) {
                CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
                CellIdentityGsm cellIdentityGsm = cellInfoGsm.getCellIdentity();
                additional_info = "cell identity " + cellIdentityGsm.getCid() + "\n"
                        + "Mobile country code " + cellIdentityGsm.getMcc() + "\n"
                        + "Mobile network code " + cellIdentityGsm.getMnc() + "\n"
                        + "local area " + cellIdentityGsm.getLac() + "\n";
            } else if (cellInfo instanceof CellInfoLte) {
                CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
                CellIdentityLte cellIdentityLte = cellInfoLte.getCellIdentity();
                additional_info = "cell identity " + cellIdentityLte.getCi() + "\n"
                        + "Mobile country code " + cellIdentityLte.getMcc() + "\n"
                        + "Mobile network code " + cellIdentityLte.getMnc() + "\n"
                        + "physical cell " + cellIdentityLte.getPci() + "\n"
                        + "Tracking area code " + cellIdentityLte.getTac() + "\n";
            } else if (cellInfo instanceof CellInfoWcdma){
                CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
                CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
                additional_info = "cell identity " + cellIdentityWcdma.getCid() + "\n"
                        + "Mobile country code " + cellIdentityWcdma.getMcc() + "\n"
                        + "Mobile network code " + cellIdentityWcdma.getMnc() + "\n"
                        + "local area " + cellIdentityWcdma.getLac() + "\n";
            }
            return additional_info;
    }
}

So, if device under test doesn't support LTE, you can always obtain other related information about its connection. Hope you can find it useful.

like image 68
johnny_kb Avatar answered Oct 03 '22 16:10

johnny_kb