How to get LTE cell location in android?

I see that we have classes for CDMACellLocation and GSMCellLocation, but there is nothing specific for LTE. Can I locate the LTE cell for my telephony service context? Thank!

+5
source share
3 answers

Be careful: although the API can provide an interface for cell information, it really depends on the media. Unlike CDMA, which could provide course location information as part of its RADIUS output, LTE is implementation dependent. Only the "lower" levels of the LTE network know where you could be, and this is fuzzy at best. Not knowing your carrier infrastructure, how their MME works, etc., you can get information, but I do not trust it with geographical location information.

In addition, it depends on how your polls operators. Depending on the profile of the device, you can poll once a minute, once every five minutes, once every two hours. If you are roaming, you can get nothing but garbage, as there are no good standards for values.

0
source

LTE, , CellInfo.

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

, ; :

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;
    }
}

, LTE, . , .

0

You can iterate over the List returned by getAllCellInfo () and check if CellInfo is CellInfoLte or not

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> cellInfoList = tm.getAllCellInfo();
for (CellInfo cellInfo : cellInfoList)
{
    if (cellInfo instanceof CellInfoLte)
    {
        // cast to CellInfoLte and call all the CellInfoLte methods you need
    }
}
-1
source

All Articles