我正在尝试在Android中识别3G网络中的相邻单元位置,这是通过getNeighboringCellInfo()获取的。当手机处于GSM模式时,我能够使用getCid()和getLac()来获取单元ID和位置区码,但是在3G模式下,我只能使用getPsc(),并不确定它是否足以识别一个单元。
请问是否有可能获取相邻单元的单元ID和LAC?如果不可能,如何使用PSC代码来识别一个单元?
请问是否有可能获取相邻单元的单元ID和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);
}
}
getPsc()
еЏҮд»ӨжӘеёёе·ӨдҢњпәџе¦‚жһњж‚ЁиѓҢе›һе¤Қ我将дёҚиѓњж„џжүЂгЂ‚ - Dheeraj Vepakomma