相邻单元的CID和LAC为-1

时间:2012-02-21 17:16:11

标签: android cell

在Android中,我尝试获取邻居小区信息。我使用以下代码

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<NeighboringCellInfo> neighborCells = telephonyManager.getNeighboringCellInfo();
if (neighborCells == null) {
    Log.d("cells", "Neighbor cells is null");
} else {
    for (NeighboringCellInfo cell : neighborCells) {
        Log.d("cells", cell.getCid()+"-"+cell.getLac()+" "+(-113+cell.getRssi()*2)+"dB");
    }
}

使用logcat,我得到以下输出

D/cells   ( 7668): Neighbor cell: -1--1 -81dB
D/cells   ( 7668): Neighbor cell: -1--1 -113dB
D/cells   ( 7668): Neighbor cell: -1--1 -113dB
你知道为什么吗?它与硬件有关吗?使用另一部手机,我总是“邻居小区为空”

谢谢

2 个答案:

答案 0 :(得分:1)

检查您是否使用CDMA手机或GSM手机。 NeighboringCellInfo仅适用于GSM手机,因为您没有相邻的CDMA塔。 CDMA具有全球唯一的网络ID。

    TelephonyManager mManager_;
     mManager_ = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    if(mManager_.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA){

        //CDMA PHONE

    }   

    else if(mManager_.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM){

        //GSM PHONE

    }

    uses permission: android.permission.ACCESS_NETWORK_STATE

希望这有帮助!

答案 1 :(得分:0)

好的,我找到了解决方案,我需要启用选项&#34;只使用2G网络&#34;。什么是好的是从我的应用程序启用该选项的可能性。 It seems这不可能,但奇怪,因为this application做到了......

有人知道为什么我有2G以上的信息而不是3G?