當前位置: 首頁>>代碼示例>>Java>>正文


Java SignalStrength類代碼示例

本文整理匯總了Java中android.telephony.SignalStrength的典型用法代碼示例。如果您正苦於以下問題:Java SignalStrength類的具體用法?Java SignalStrength怎麽用?Java SignalStrength使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SignalStrength類屬於android.telephony包,在下文中一共展示了SignalStrength類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupSignalStrength

import android.telephony.SignalStrength; //導入依賴的package包/類
private void setupSignalStrength() {
    final TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    final ImageView signalIcon = ((ImageView) statusBar.findViewById(R.id.signal_icon));
    phoneListener = new PhoneStateListener() {
        @Override
        public void onSignalStrengthsChanged(SignalStrength signalStrength) {
            if (manager.getNetworkOperator().equals("")) {
                signalIcon.setVisibility(View.GONE);
            } else {
                signalIcon.setVisibility(View.VISIBLE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    // See https://github.com/AlstonLin/TheLearningLock/issues/54
                    Integer imageRes = signalStrengthToIcon.get(signalStrength.getLevel());
                    if (imageRes != null) signalIcon.setImageResource(imageRes);
                    else signalIcon.setImageResource(signalStrengthToIcon.get(4));
                } else {
                    // Just show the full icon
                    signalIcon.setImageResource(signalStrengthToIcon.get(4));
                }
            }
        }
    };
    manager.listen(phoneListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
 
開發者ID:AlstonLin,項目名稱:TheLearningLock,代碼行數:25,代碼來源:StatusBar.java

示例2: onSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
/**
 *  Description:  TODO: add more info
 *
 *  Issues:
 *
 *      [ ]     Getting and comparing signal strengths between different RATs can be very
 *              tricky, since they all return different ranges of values. AOS doesn't
 *              specify very clearly what exactly is returned, even though people have
 *              a good idea, by trial and error.
 *
 *              See note in : SignalStrengthTracker.java
 *
 *  Notes:
 *
 *
 *
 */
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    // Update Signal Strength
    if (signalStrength.isGsm()) {
        int dbm;
        if (signalStrength.getGsmSignalStrength() <= 2 ||
                signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
            // Unknown signal strength, get it another way
            String[] bits = signalStrength.toString().split(" ");
            dbm = Integer.parseInt(bits[9]);
        } else {
            dbm = signalStrength.getGsmSignalStrength();
        }
        mDevice.setSignalDbm(dbm);
    } else {
        int evdoDbm = signalStrength.getEvdoDbm();
        int cdmaDbm = signalStrength.getCdmaDbm();

        // Use lowest signal to be conservative
        mDevice.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
    }
    // Send it to signal tracker
    signalStrengthTracker.registerSignalStrength(mDevice.mCell.getCID(), mDevice.getSignalDBm());
    //signalStrengthTracker.isMysterious(mDevice.mCell.getCID(), mDevice.getSignalDBm());
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:42,代碼來源:CellTracker.java

示例3: phoneSignalStrengthsUpdated

import android.telephony.SignalStrength; //導入依賴的package包/類
@Override
public void phoneSignalStrengthsUpdated(SignalStrength signalStrength) {
    WritableMap map = Arguments.createMap();
    map.putInt("cdmaDbm", signalStrength.getCdmaDbm());
    map.putInt("cdmaEcio()", signalStrength.getCdmaEcio());
    map.putInt("evdoDbm", signalStrength.getEvdoDbm());
    map.putInt("evdoEcio", signalStrength.getEvdoEcio());
    map.putInt("evdoSnr", signalStrength.getEvdoSnr());
    map.putInt("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
    map.putInt("gsmSignalStrength", signalStrength.getGsmSignalStrength());
    map.putBoolean("gsm", signalStrength.isGsm());

    WritableMap result = Arguments.createMap();
    result.putString("type", "LISTEN_SIGNAL_STRENGTHS");
    result.putMap("data", map);

    sendEvent(PHONE_STATE_LISTENER, result);
}
 
開發者ID:rafaellincoln,項目名稱:react-native-telephony,代碼行數:19,代碼來源:TelephonyModule.java

示例4: updateSignalStrength

import android.telephony.SignalStrength; //導入依賴的package包/類
private void updateSignalStrength(SignalStrength signalStrength) {
    final int level;
    Log.i(TAG, "updateSignalStrength: ");
    if(!isCdma(signalStrength)) {
        int asu = signalStrength.getGsmSignalStrength();
        // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
        // asu = 0 (-113dB or less) is very weak
        // signal, its better to show 0 bars to the user in such cases.
        // asu = 99 is a special case, where the signal strength is unknown.
        if(asu <= 2 || asu == 99) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_NO_BAR;
        else if(asu >= 12) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_FOUR_BAR;
        else if(asu >= 8) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_THREE_BAR;
        else if(asu >= 5) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_TWO_BAR;
        else level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_ONE_BAR;
    } else {
        level = getCdmaLevel(signalStrength);
    }

    if(level != sCurrentSignalStrength) {
        sCurrentSignalStrength = level;

        MBApp application = MBApp.getApp();

        Intent intent = new Intent(application, IPCService.class);
        intent.putExtra(IPCConstants.INTENT_TYPE, EventCategories.IPC_BLE_NOTIFICATION_CHARACTERISTIC_CHANGED);
        intent.putExtra(IPCConstants.INTENT_CHARACTERISTIC_MESSAGE, Utils.makeMicroBitValue
                (EventCategories.SAMSUNG_SIGNAL_STRENGTH_ID, level));
        application.startService(intent);
    }
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:31,代碼來源:SignalStrengthPresenter.java

示例5: getCdmaLevel

import android.telephony.SignalStrength; //導入依賴的package包/類
private int getCdmaLevel(SignalStrength signalStrength) {
    final int cdmaDbm = signalStrength.getCdmaDbm();
    final int cdmaEcio = signalStrength.getCdmaEcio();

    final int levelDbm;
    if(cdmaDbm >= -75) levelDbm = 4;
    else if(cdmaDbm >= -85) levelDbm = 3;
    else if(cdmaDbm >= -95) levelDbm = 2;
    else if(cdmaDbm >= -100) levelDbm = 1;
    else levelDbm = 0;

    final int levelEcio;
    // Ec/Io are in dB*10
    if(cdmaEcio >= -90) levelEcio = 4;
    else if(cdmaEcio >= -110) levelEcio = 3;
    else if(cdmaEcio >= -130) levelEcio = 2;
    else if(cdmaEcio >= -150) levelEcio = 1;
    else levelEcio = 0;

    return (levelDbm < levelEcio) ? levelDbm : levelEcio;
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:22,代碼來源:SignalStrengthPresenter.java

示例6: onSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
/**
 *  Description:  TODO: add more info
 *
 *  Issues:
 *
 *      [ ]     Getting and comparing signal strengths between different RATs can be very
 *              tricky, since they all return different ranges of values. AOS doesn't
 *              specify very clearly what exactly is returned, even though people have
 *              a good idea, by trial and error.
 *
 *              See note in : SignalStrengthTracker.java
 */
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    // Update Signal Strength
    if (signalStrength.isGsm()) {
        int dbm;
        if (signalStrength.getGsmSignalStrength() <= 2 ||
                signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
            // Unknown signal strength, get it another way
            String[] bits = signalStrength.toString().split(" ");
            dbm = Integer.parseInt(bits[9]);
        } else {
            dbm = signalStrength.getGsmSignalStrength();
        }
        device.setSignalDbm(dbm);
    } else {
        int evdoDbm = signalStrength.getEvdoDbm();
        int cdmaDbm = signalStrength.getCdmaDbm();

        // Use lowest signal to be conservative
        device.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
    }
    // Send it to signal tracker
    signalStrengthTracker.registerSignalStrength(device.cell.getCellId(), device.getSignalDBm());
    //signalStrengthTracker.isMysterious(device.cell.getCid(), device.getSignalDBm());
}
 
開發者ID:anticomarley,項目名稱:Android-IMSI-Catcher-Detector,代碼行數:37,代碼來源:CellTracker.java

示例7: getFirstValid

import android.telephony.SignalStrength; //導入依賴的package包/類
public static double getFirstValid(SignalStrength signalStrength) {
    for (SignalMethod method : methods) {
        if (method.isExcluded()) continue;

        double level;
        try {
            level = method.getLevel(signalStrength);
        } catch (Exception e) {
            continue;
        }

        if (SignalUtils.isValidLevel(level) && level > 0)
            return level;
    }

    return 0;
}
 
開發者ID:TheAndroidMaster,項目名稱:SignalStrengths,代碼行數:18,代碼來源:SignalStrengths.java

示例8: onSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
/**
         * signalStrength.isGsm()           是否GSM信號 2G or 3G
         * signalStrength.getCdmaDbm();     聯通3G 信號強度
         * signalStrength.getCdmaEcio();    聯通3G 載幹比
         * signalStrength.getEvdoDbm();     電信3G 信號強度
         * signalStrength.getEvdoEcio();    電信3G 載幹比
         * signalStrength.getEvdoSnr();     電信3G 信噪比
         * signalStrength.getGsmSignalStrength();  2G 信號強度
         * signalStrength.getGsmBitErrorRate();    2G 誤碼率
         * 載幹比 ,它是指空中模擬電波中的信號與噪聲的比值
         */
        @Override
        public void onSignalStrengthsChanged(SignalStrength signalStrength) {
            super.onSignalStrengthsChanged(signalStrength);
            Log.d(TAG, "onSignalStrengthsChanged() called with " + "signalStrength :"+signalStrength+";\n gsmSignalStrength = [" + signalStrength.getGsmSignalStrength() + "]");

//            if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
//                mTvSignalInfo.setText("GSM Strength" + signalStrength.getGsmSignalStrength());
//            } else if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
//                mTvSignalInfo.setText("CDMA Strength" + signalStrength.getCdmaDbm() + " dBm");
//            } else {
//                mTvSignalInfo.setText("Unknown PhoneType: " + mTelephonyManager.getPhoneType());
//            }

            mTvSignalInfo.setText("IsGsm : " + signalStrength.isGsm() +
                    "\nCDMA Dbm : " + signalStrength.getCdmaDbm() + " Dbm" +
                    "\nCDMA Ecio : " + signalStrength.getCdmaEcio() +  " dB*10" +
                    "\nEvdo Dbm : " + signalStrength.getEvdoDbm() + " Dbm" +
                    "\nEvdo Ecio : " + signalStrength.getEvdoEcio() + " dB*10" +
                    "\nGsm SignalStrength : " + signalStrength.getGsmSignalStrength() +
                    "\nGsm BitErrorRate : " + signalStrength.getGsmBitErrorRate());



        }
 
開發者ID:AlanCheen,項目名稱:PracticeDemo,代碼行數:36,代碼來源:DeviceInfoActivty.java

示例9: onSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    long now = System.currentTimeMillis();
    if (signalStrength.isGsm()) {
        Log.d(TAG,
                "GSM Signal Strength: "
                        + signalStrength.getGsmSignalStrength() + ", "
                        + signalStrength.getGsmBitErrorRate());
    } else {
        Log.d(TAG,
                "CDMA Signal Strength: " + signalStrength.getCdmaDbm()
                        + ", " + signalStrength.getCdmaEcio());
    }

    putValueTrimSize(IS_GSM_FIELD, null, now, signalStrength.isGsm());
    putValueTrimSize(GSM_SIGNAL_STRENGTH_FIELD, null, now, signalStrength.getGsmSignalStrength());
    putValueTrimSize(GSM_BIT_ERROR_RATE_FIELD, null, now, signalStrength.getGsmBitErrorRate());
    putValueTrimSize(CDMA_DBM_FIELD, null, now, signalStrength.getCdmaDbm());
    putValueTrimSize(CDMA_ECIO_FIELD, null, now, signalStrength.getCdmaEcio());
    putValueTrimSize(EVDO_DBM_FIELD, null, now, signalStrength.getEvdoDbm());
    putValueTrimSize(EVDO_ECIO_FIELD, null, now, signalStrength.getEvdoEcio());
    putValueTrimSize(EVDO_SNR_FIELD, null, now, signalStrength.getEvdoSnr());
}
 
開發者ID:swandroid,項目名稱:swan-sense-studio,代碼行數:24,代碼來源:SignalStrengthSensor.java

示例10: onSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
	long now = System.currentTimeMillis();
	if (signalStrength.isGsm()) {
		Log.d(TAG,
				"GSM Signal Strength: "
						+ signalStrength.getGsmSignalStrength() + ", "
						+ signalStrength.getGsmBitErrorRate());
	} else {
		Log.d(TAG,
				"CDMA Signal Strength: " + signalStrength.getCdmaDbm()
						+ ", " + signalStrength.getCdmaEcio());
	}

	putValueTrimSize(IS_GSM_FIELD, null, now, signalStrength.isGsm());
	putValueTrimSize(GSM_SIGNAL_STRENGTH_FIELD, null, now, signalStrength.getGsmSignalStrength());
	putValueTrimSize(GSM_BIT_ERROR_RATE_FIELD, null, now, signalStrength.getGsmBitErrorRate());
	putValueTrimSize(CDMA_DBM_FIELD, null, now, signalStrength.getCdmaDbm());
	putValueTrimSize(CDMA_ECIO_FIELD, null, now, signalStrength.getCdmaEcio());
	putValueTrimSize(EVDO_DBM_FIELD, null, now, signalStrength.getEvdoDbm());
	putValueTrimSize(EVDO_ECIO_FIELD, null, now, signalStrength.getEvdoEcio());
	putValueTrimSize(EVDO_SNR_FIELD, null, now, signalStrength.getEvdoSnr());
}
 
開發者ID:nadinasovaiala,項目名稱:swan_sense_integration,代碼行數:24,代碼來源:SignalStrengthSensor.java

示例11: onSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
	super.onSignalStrengthsChanged(signalStrength);
	Log.i(TAG, "onSignalStrengthsChanged" + signalStrength);
	//			if(Build.VERSION.SDK_INT>=18){
	//				if(signalStrength instanceof SignalStrength){
	//					Log.i("LOG_TAG", "onSignalStrengthsChanged: getcdaRscp" + signalStrength.getDbm());
	//					int ttt = signalStrength.getDbm();
	//					text1.setText(String.valueOf(ttt));
	//				}
	//				else{
	Log.i(TAG, "onSignalStrengthsChanged: getcda dbm: " + signalStrength.getCdmaDbm());
	int ttt = signalStrength.getCdmaDbm();
	text1.setText(String.valueOf(ttt));
	//				}
	//				}
}
 
開發者ID:joaogithub,項目名稱:Testes,代碼行數:18,代碼來源:FirstActivity.java

示例12: onSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
	super.onSignalStrengthsChanged(signalStrength);
	String sim = UEDevice.getSimType(activity);
	mNavigationView.setSingalText(sim);
	if (sim.equals("無服務")) {
		mNavigationView.setSingalStatus(UISingalView.STATUS_NONE);
		return;
	}
	mNavigationView.setSingalStatus(UISingalView.STATUS_NORMAL);
	int level = 0;
	if (signalStrength.isGsm()) {
		level = signalStrength.getGsmSignalStrength();
	}else {
		if (sim.equals("中國電信")) {
			level = signalStrength.getCdmaDbm();
		}else {
			level = signalStrength.getEvdoDbm();
		}
	}
	if (level == 0) {
		mNavigationView.setSignal(5);
		return;
	}
	if (level < -112) {
		mNavigationView.setSignal(0);
	}else if (level >= -111 && level < -104) {
		mNavigationView.setSignal(1);
	}else if (level >= -104 && level < -97) {
		mNavigationView.setSignal(2);
	}else if (level >= -97 && level < -90) {
		mNavigationView.setSignal(3);
	}else if (level >= -90 && level < -83) {
		mNavigationView.setSignal(4);
	}else {
		mNavigationView.setSignal(5);
	}
}
 
開發者ID:Soniy7x,項目名稱:Auie,代碼行數:39,代碼來源:UENavigationActivity.java

示例13: sOnSignalStrengthsChanged

import android.telephony.SignalStrength; //導入依賴的package包/類
synchronized static void sOnSignalStrengthsChanged(SignalStrength signalStrength) {
	mData.setTime(System.currentTimeMillis());
	mData.setSignal(signalStrength);
	
	if (OtherUtils.isThisDeviceAnEmulator() == true) {
    		// The signal will usuaully be null on the Emulator...
	} else {
		// On a real device... there should generally be a signal...
		SKPorting.sAssert(CellTowersDataCollector.class, mData.getSignal() != null);
	}
	
	try {
		mData.setCellLocation(mTelManager.getCellLocation());
	} catch (SecurityException e) {
		// Seen - rarely - on some Android devices.
		// Neither user 99999 nor current process has android.permission.ACCESS_COARSE_LOCATION.
   		SKPorting.sAssert(CellTowersDataCollector.class, false);
	}
}
 
開發者ID:SamKnows,項目名稱:skandroid-core,代碼行數:20,代碼來源:CellTowersDataCollector.java

示例14: signalStrengthJSON

import android.telephony.SignalStrength; //導入依賴的package包/類
/**
 * Originates from a change in signal strength
 * @param signalStrength SignalStrength
 * @return JSON
 */
public static String signalStrengthJSON(SignalStrength signalStrength){
    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    try {
        json.put("provider", SIGNAL_STRENGTH); // Yep provider and type are same values
        json.put("type", SIGNAL_STRENGTH);
        json.put("timestamp", calendar.getTimeInMillis());
        json.put("cdmaDbm", signalStrength.getCdmaDbm());
        json.put("cdmaEcio", signalStrength.getCdmaEcio());
        json.put("evdoDbm", signalStrength.getEvdoDbm());
        json.put("evdoEcio", signalStrength.getEvdoEcio());
        json.put("evdoSnr", signalStrength.getEvdoSnr());
        json.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
        json.put("gsmSignalStrength", signalStrength.getGsmSignalStrength());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
            json.put("level", signalStrength.getLevel());
        }

        json.put("isGSM", signalStrength.isGsm());
    }
    catch(JSONException exc) {
        logJSONException(exc);
    }

    return json.toString();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:34,代碼來源:JSONHelper.java

示例15: isCdma

import android.telephony.SignalStrength; //導入依賴的package包/類
private boolean isCdma(SignalStrength signalStrength) {
    return (signalStrength != null) && !signalStrength.isGsm();
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:4,代碼來源:SignalStrengthPresenter.java


注:本文中的android.telephony.SignalStrength類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。