저는 현재 프로젝트 뷰어 응용 프로그램 매개 변수 인 2G 및 3G에서 작업하고 있습니다.
나는 rxqual 및 RX 수준을 보여주고 싶은, 그리고 네트워크가 3G 네트워크에서 감지되고, 수신 레벨 rxQual이 값 Ec/N0 및 RSSI으로 변합니다,하지만 난 문제를 얻을 때, 나는 networktype = getNetworkTypeString (tm.getNetworkType());
과 함께
getnetworktype()
를 사용 하지만 RxQual 및 RXLEV이 아닌 값 Ec/N0 및 RSSI로 변신, 그래서 뭔가가 누락되거나 잘못되면, 내 코드를 확인하시기 바랍니다 조직을 얻을 해당하는 네트워크 유형을 변경하지 않으 ..
이 내 코드입니다 :네트워크 유형을 연속적으로 얻는 방법?
public class MainActivity extends Activity
{
//private static final Logger logger = LoggerFactory.getLogger;
protected String APP_NAME;
LogWriter lw;
PhoneStateListener myPhoneStateListener;
int cid, lac, mcc, mnc,kuatlevel,kualitas,kw3g;
String operator, networktype, networkOperator, type, cellinfo;
GsmCellLocation location;
TelephonyManager tm;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//((Object) PropertyConfigurator.getConfigurator(this)).configure();
tm = (TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(phoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION
|PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
location =((GsmCellLocation)tm.getCellLocation());
operator = tm.getNetworkOperatorName();
networkOperator = tm.getNetworkOperator();
if (networkOperator !=null && networkOperator.length() > 0){
try {
mcc = Integer.parseInt(networkOperator.substring(0, 3));
mnc = Integer.parseInt(networkOperator.substring(3));
} catch (NumberFormatException e){`enter code here`
}
}
networktype = getNetworkTypeString(tm.getNetworkType());
List<NeighboringCellInfo> cellinfo = tm.getNeighboringCellInfo();
if (null != cellinfo){
for(NeighboringCellInfo info : cellinfo){
((TextView)findViewById(R.id.neighbor)).setText("CID:"+(info.getCid()& 0xffff) +
" LAC:"+(info.getLac()& 0xffff));
}
}
((TextView)findViewById(R.id.mnc)).setText("MNC: " + mnc);
((TextView)findViewById(R.id.mcc)).setText("MCC: " + mcc);
((TextView)findViewById(R.id.operatorname)).setText("Operator: " + operator);
//((TextView)findViewById(R.id.networkType)).setText("Network Type: " + networktype);
}
private final PhoneStateListener phoneStateListener = new PhoneStateListener()
{
public void onCellLocationChanged(CellLocation location) {
GsmCellLocation gsmLocation = (GsmCellLocation)location;
setTextViewText(R.id.lac,String.valueOf("LAC: " + (gsmLocation.getLac()& 0xffff)));
setTextViewText(R.id.cid,String.valueOf("CID: " + (gsmLocation.getCid()& 0xffff)));
setTextViewText(R.id.networkType,String.valueOf("Network Type: " + (networktype)));
}
public void onSignalStrengthsChanged(SignalStrength signalStrength){
kualitas = signalStrength.getGsmBitErrorRate();
kw3g = -1 * (signalStrength.getGsmBitErrorRate());
kuatlevel = -113 + 2 *(signalStrength.getGsmSignalStrength());
if (networktype == "2G"){
setTextViewText(R.id.rxq_ecno,String.valueOf("RxQ: " + (kualitas)));
setTextViewText(R.id.rxl_rssi,String.valueOf("RxL: " + (kuatlevel) + " dBm"));
} else {
setTextViewText(R.id.rxq_ecno,String.valueOf("EcNo: " + (kw3g) + " dB"));
setTextViewText(R.id.rxl_rssi,String.valueOf("RSSI: " + (kuatlevel) + " dBm"));
setTextViewText(R.id.arfcn_rscp,String.valueOf("RSCP: " + (kuatlevel + kw3g) + " dBm"));
}
}
};
private String getNetworkTypeString(int Ntype) {
type = "unknown";
switch (Ntype) {
case TelephonyManager.NETWORK_TYPE_EDGE:type = "2G"; break;
case TelephonyManager.NETWORK_TYPE_GPRS:type = "2G"; break;
case TelephonyManager.NETWORK_TYPE_UMTS:type = "3G"; break;
case TelephonyManager.NETWORK_TYPE_1xRTT:type = "2G"; break;
case TelephonyManager.NETWORK_TYPE_HSDPA:type = "3G"; break;
default:
type = "unknown"; break;
}
// TODO Auto-generated method stub
return type;
}
protected void setTextViewText(int id, String text) {
((TextView)findViewById(id)).setText(text);
// TODO Auto-generated method stub
}
//public static Logger getLogger() {
// return logger;
//}
}