8

getNeighboringCellInfo() で取得した Android で 3G の隣接セルの位置を特定しようとしています。電話が GSM モードで動作している場合、getCid() と getLac() を使用して CellID と LAC を取得できますが、3G の場合は getPsc() しか使用できず、これで十分かどうかはよくわかりません。セルを識別します。

隣接するセルの CellID + LAC を取得できるかどうか教えてください。それが不可能な場合、どのように PSC コードを使用して細胞を識別することができますか?

4

3 に答える 3

3

隣接セルのcidとrssiを取得できます。したがって、このコードを試してみると、物理的な素材でのみ機能します(エミュレーターは使用しないでください)。ここでは、textviewを使用してAndroidxmlを作成します。;-)

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);
 }   
 }
于 2012-03-29T15:15:32.907 に答える