【问题标题】:How to get cell id for 3G network?如何获取 3G 网络的小区 ID?
【发布时间】:2014-01-13 22:36:45
【问题描述】:

我得到了错误的 3G 网络小区 ID,我得到了正确的 2G 小区 ID 值, 我不明白我哪里错了。请帮忙

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager
                .getCellLocation();

        //Cell Id, LAC 
        int cid = cellLocation.getCid();
        int lac = cellLocation.getLac();

        //MCC
        String MCC =telephonyManager.getNetworkOperator();
        int mcc = Integer.parseInt(MCC.substring(0, 3));
        String mcc1 = String.valueOf(mcc);

        //Operator name
        String operatoprName = telephonyManager.getNetworkOperatorName();

我还授予了AndroiManifest.xml文件ACCESS_COARSE_LOCATIONACCESS_NETWORK_STATE

的权限

【问题讨论】:

  • 请回答。

标签: java android 3g cellid


【解决方案1】:

解决方案在以下线程中突出显示:Android: CellID not available on all carriers?

简而言之,您需要在 3G 网络中使用 0xffff 屏蔽从 getCid() 获得的数字。 下面是一个sn-p:

GsmCellLocation cellLocation = (GsmCellLocation)telm.getCellLocation();

new_cid = cellLocation.getCid() & 0xffff;
new_lac = cellLocation.getLac() & 0xffff;

希望有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-30
    • 1970-01-01
    • 1970-01-01
    • 2012-10-03
    • 1970-01-01
    • 2012-10-11
    • 1970-01-01
    相关资源
    最近更新 更多