我試圖用getNeighboringCellInfo()獲得3G中與Android相鄰的單元位置。當手機以GSM模式工作時,我可以使用getCid()和getLac()獲取CellID和LAC,但對於3G,我只能使用getPsc(),我不太確定它是否足夠確定一個細胞。Android的3G相鄰單元的cellID和LAC/PSC
任何人都可以告訴我,如果我可以得到相鄰細胞的CellID + LAC?如果這是不可能的,我如何使用PSC代碼來識別單元?
我試圖用getNeighboringCellInfo()獲得3G中與Android相鄰的單元位置。當手機以GSM模式工作時,我可以使用getCid()和getLac()獲取CellID和LAC,但對於3G,我只能使用getPsc(),我不太確定它是否足夠確定一個細胞。Android的3G相鄰單元的cellID和LAC/PSC
任何人都可以告訴我,如果我可以得到相鄰細胞的CellID + LAC?如果這是不可能的,我如何使用PSC代碼來識別單元?
我可以得到相鄰單元格的cid和rssi。所以你試試這個代碼,它只適用於物理材料(不要使用模擬器)。 在這裏你可以用textview創建你的android xml。 ;-)
package app.tel;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.widget.TextView;
public class TelephActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textGsmCellLocation = (TextView)findViewById(R.id.gsmcelllocation);
TextView textMCC = (TextView)findViewById(R.id.mcc);
TextView textMNC = (TextView)findViewById(R.id.mnc);
TextView textCID = (TextView)findViewById(R.id.cid);
//retrieve a reference to an instance of TelephonyManager
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();
String networkOperator = telephonyManager.getNetworkOperator();
String mcc = networkOperator.substring(0, 3);
String mnc = networkOperator.substring(3);
textMCC.setText("mcc: " + mcc);
textMNC.setText("mnc: " + mnc);
int cid = cellLocation.getCid();
//int lac = cellLocation.getLac();
textGsmCellLocation.setText(cellLocation.toString());
textCID.setText("gsm cell id: " + String.valueOf(cid));
TextView Neighboring = (TextView)findViewById(R.id.neighboring);
List<NeighboringCellInfo> NeighboringList = telephonyManager.getNeighboringCellInfo();
String stringNeighboring = "Neighboring List- Lac : Cid : RSSI\n";
for(int i=0; i < NeighboringList.size(); i++){
String dBm;
int rssi = NeighboringList.get(i).getRssi();
if(rssi == NeighboringCellInfo.UNKNOWN_RSSI){
dBm = "Unknown RSSI";
}else{
dBm = String.valueOf(-113 + 2 * rssi) + " dBm";
}
stringNeighboring = stringNeighboring
+ String.valueOf(NeighboringList.get(i).getLac()) +" : "
+ String.valueOf(NeighboringList.get(i).getCid()) +" : "
+ String.valueOf(NeighboringList.get(i).getPsc()) +" : "
+ String.valueOf(NeighboringList.get(i).getNetworkType()) +" : "
+ dBm +"\n";
}
Neighboring.setText(stringNeighboring);
}
}
這不回答這個問題。在UMTS(HSPA)連接的情況下,cid和lac未設置。 – 2013-11-15 16:04:20
在UMTS中,PSC是一種本地小區標識符。它是「本地」獨特的,因爲所有相鄰小區以及這些小區的所有鄰居都保證具有與當前小區不同的PSC。這也意味着你將永遠不會遇到具有相同PSC的兩個相鄰小區。然而,很可能有位於該國不同地區的具有相同PSC的小區。
UMTS小區的NeighboringCellInfo將只有PSC設置,而所有其他字段(MCC,MNC,LAC,CID)將無效。找出這些參數的唯一方法是存儲所遇到的每個單元的所有字段(MCC,MNC,LAC,CID以及PSC),然後在獲得「未知」PSC時在存儲的數據中查找它。 (您需要篩選服務小區的鄰居,因爲PSC只是本地唯一的ID,而不是全球唯一的ID)。
作爲替代方案,小區的PSC以及其鄰居之一的MCC/MNC/LAC/CID元組也是您可以使用的全局唯一ID。但是請注意,每個單元格都有多個這樣的標識符(每個鄰居都有一個)。
有時候,當同一供應商的更多CID共享相同的塔/站點(用於增加容量並以相同的調度進行傳輸時)具有相同的PSC。所以在這些情況下,您可以使用PSC來識別站點和波束方向,但不能識別CID。
你能告訴我你在哪個手機型號和Android版本中找到'getPsc()'工作嗎?欣賞它,如果你可以回覆。 – 2012-07-03 05:26:11
我得到了同樣的問題,對於UTMS網絡,它只是不能獲得cellId和lac,但它與當前連接的蜂窩塔適用。我認爲它不能得到當前API級別的鄰居cellid。 – 2013-10-09 16:45:42