2012-02-21 74 views
0

在Android中,我嘗試獲取鄰居小區信息。我用下面的代碼鄰居小區對於CID和LAC有-1 -1

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 

你知道爲什麼嗎?它與硬件有關嗎?與另一個電話,我總是得到「相鄰小區爲空」

謝謝

回答

0

好的我找到了解決方案,我需要啓用選項「只使用2G網絡」。從我的應用程序啓用該選項的可能性很大。 It seems這是不可能的,但奇怪,因爲this application這樣做...

有人知道我爲什麼有更多的信息與2G的細胞比3G?

1

檢查youu使用的是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 

希望這有助於!

+0

謝謝,但我使用的是GSM手機 – 2012-02-22 09:31:33

相關問題