Android中的3G邻居小区的cellID和LAC/PSC

mod*_*ero 8 android location cellid 3g

我试图用Android识别3G中的相邻小区位置,我用getNeighboringCellInfo()来获取.当手机在GSM模式下工作时,我可以使用getCid()和getLac()来获取CellID和LAC,但对于3G,我只能使用getPsc(),我不太确定它是否足够识别一个细胞.

任何人都可以告诉我,我是否可以获得相邻细胞的CellID + LAC?如果那是不可能的,我如何使用PSC代码来识别一个单元?

13K*_*3KZ 3

我可以获得相邻小区的 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);
 }   
 }
Run Code Online (Sandbox Code Playgroud)