本文整理匯總了Java中android.telephony.SignalStrength.getGsmSignalStrength方法的典型用法代碼示例。如果您正苦於以下問題:Java SignalStrength.getGsmSignalStrength方法的具體用法?Java SignalStrength.getGsmSignalStrength怎麽用?Java SignalStrength.getGsmSignalStrength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.telephony.SignalStrength
的用法示例。
在下文中一共展示了SignalStrength.getGsmSignalStrength方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
示例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());
}
示例3: 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);
}
}
示例4: 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());
}
示例5: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
if (isRegistered) {
int level = signalStrength.getGsmSignalStrength();
if (level > 4) level /= 7.75;
else if (level < 1) {
int strength = signalStrength.getCdmaDbm();
if (strength < -100) level = 0;
else if (strength < -95) level = 1;
else if (strength < -85) level = 2;
else if (strength < -75) level = 3;
else if (strength != 0) level = 4;
else {
strength = signalStrength.getEvdoDbm();
if (strength == 0 || strength < -100) level = 0;
else if (strength < -95) level = 1;
else if (strength < -85) level = 2;
else if (strength < -75) level = 3;
else level = 4;
}
}
onDrawableUpdate(level);
}
}
示例6: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
int percent = 0;
if(signalStrength != null && signalStrength.getGsmSignalStrength() != UNKNOWN_CODE) {
percent = calculateSignalStrengthInPercent(signalStrength.getGsmSignalStrength());
} else {
Log.e(TAG, "Unable to get phone signal strength!");
}
onPercentKnown(percent);
}
示例7: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
//Log.e(Tag, signalStrength.toString());
get_Reflection_Method(signalStrength);
try {
Method getLteRsrp = signalStrength.getClass().getDeclaredMethod("getLteRsrp");
getLteRsrp.setAccessible(true);
lte_RSRP = (int) getLteRsrp.invoke(signalStrength);
Method getLteRsrq = signalStrength.getClass().getDeclaredMethod("getLteRsrq");
getLteRsrq.setAccessible(true);
lte_RSRQ = (int) getLteRsrq.invoke(signalStrength);
Method getLteRssnr = signalStrength.getClass().getDeclaredMethod("getLteRssnr");
getLteRssnr.setAccessible(true);
lte_SINR = (int) getLteRssnr.invoke(signalStrength);
cdma_RxPwr = signalStrength.getCdmaDbm();
cdma_EcIo = signalStrength.getCdmaEcio();
gsm_RSSI = signalStrength.getGsmSignalStrength();
getWcdmaSignalStrength();
((MainActivity)mcontext).mSectionsPagerAdapter.notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
}
getCellIdentity();
}
示例8: updateSignalStrengths
import android.telephony.SignalStrength; //導入方法依賴的package包/類
private void updateSignalStrengths(SignalStrength signalStrength){
/** Current cell */
TextView cellSignalStrength_Asu_dBm = (TextView)findViewById(R.id.cellsignalstrength_Asu_dBm);
TextView cellBitErrorRate = (TextView)findViewById(R.id.cellbiterrorrate);
if (signalStrength!=null){
int asu = signalStrength.getGsmSignalStrength();
cellSignalStrength_Asu_dBm.setText(String.valueOf(asu)+"/"+String.valueOf(-113+(2*asu)));
cellBitErrorRate.setText(String.valueOf(signalStrength.getGsmBitErrorRate()));
} else {
cellSignalStrength_Asu_dBm.setText("NA/NA");
cellBitErrorRate.setText("NA");
}
}
示例9: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// TODO Auto-generated method stub
super.onSignalStrengthsChanged(signalStrength);
gsmSignal = signalStrength.getGsmSignalStrength();
cdmaDbm = signalStrength.getCdmaDbm();
evdoDbm = signalStrength.getEvdoDbm();
}
示例10: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
if (signalStrength.isGsm()) {
if (signalStrength.getGsmSignalStrength() != 99) {
// this is the equation used to convert a valid gsm signal to dbm.
setCellSignalStrength(signalStrength.getGsmSignalStrength() * 2 - 113);
} else {
setCellSignalStrength(signalStrength.getGsmSignalStrength());
}
} else {
setCellSignalStrength(signalStrength.getCdmaDbm());
}
}
示例11: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
/**
* Called when the signal strength has changed
*
* @param signalStrength
* strength of the newly detected signal. First, we get the ASU
* by calling getGsmSignalStrength(), then we calculate the dBm
* through dBm = -113 + 2* ASU
* @see android.telephony.PhoneStateListener#onSignalStrengthsChanged(android.telephony.SignalStrength)
*/
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
int strength, signal;
// signal strength in ASU
strength = signalStrength.getGsmSignalStrength();
// convert ASU in dBm
signal = -113 + 2 * strength;
// has anything changed?
if (signal != oldcellStrength) {
// convert ASU into bars
if (strength <= 2 || strength == 99)
oldcellStrength_bar = 0;
else if (strength >= 12)
oldcellStrength_bar = 4;
else if (strength >= 8)
oldcellStrength_bar = 3;
else if (strength >= 5)
oldcellStrength_bar = 2;
else
oldcellStrength_bar = 1;
oldcellStrength = signal;
// stuff can be read now
signal_read = true;
bar_read = true;
// release semaphores
signal_semaphore.release();
bar_semaphore.release();
}
}
示例12: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signal) {
super.onSignalStrengthsChanged(signal);
int signalStrength = signal.getGsmSignalStrength();
if (mTelephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE && 0 <= signalStrength && signalStrength <= 97)
signalStrength = getSignalStrengthLTE(signal);
setSignalStrength(signalStrengthAsuToDbm(signalStrength, mTelephonyManager.getNetworkType()));
updateItems();
notifyListeners();
}
示例13: getSignalStrength
import android.telephony.SignalStrength; //導入方法依賴的package包/類
protected int getSignalStrength(SignalStrength signal) {
String ssignal = signal.toString();
String[] parts = ssignal.split(" ");
int dB = -120; // No Signal Measured when returning -120 dB
// If LTE
if (telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE){
int ltesignal = Integer.parseInt(parts[9]);
// check to see if it get's the right signal in dB, a signal below -2
if(ltesignal < -2) {
dB = ltesignal;
}
}
// Else 3G
else {
if (signal.getGsmSignalStrength() != 99) {
int strengthInteger = -113 + 2 * signal.getGsmSignalStrength();
dB = strengthInteger;
}
}
return dB;
}
示例14: onSignalStrengthsChanged
import android.telephony.SignalStrength; //導入方法依賴的package包/類
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
int strength = -1;
dbm = -1024;
if (signalStrength.isGsm()) {
if (signalStrength.getGsmSignalStrength() != 99) {
dbm = signalStrength.getGsmSignalStrength() * 2 - 113;
} else {
dbm = signalStrength.getGsmSignalStrength();
}
} else {
dbm = signalStrength.getCdmaDbm();
}
oldTime = System.currentTimeMillis();
if (dbm <= -111) {
strength = 0;
} else if (dbm <= -99 && dbm >= -110) {
strength = 1;
} else if (dbm <= -86 && dbm >= -98) {
strength = 2;
} else if (dbm <= -74 && dbm >= -85) {
strength = 3;
} else if ((dbm <= -61 && dbm >= -73) || (dbm >= 60 && dbm < 99)) {
strength = 4;
} else {
viewBeforeSignal.setVisibility(View.GONE);
txtStatusSignal.setVisibility(View.GONE);
}
if (strength != -1) {
viewBeforeSignal.setVisibility(View.VISIBLE);
txtStatusSignal.setVisibility(View.VISIBLE);
txtStatusSignal.setText(getString(R.string.txtStatusSignal)
+ " " + strength + " bars");
txtStatusSignal
.setContentDescription(getString(R.string.txtStatusSignal)
+ " " + strength + " bars");
attachListener(txtStatusSignal);
}
}
示例15: getGsmSignalStrength
import android.telephony.SignalStrength; //導入方法依賴的package包/類
public static int getGsmSignalStrength(SignalStrength signalStrength) {
// Work-around problem shown by Android devices!
// http://strangedevexperience.blogspot.co.uk/2013_03_01_archive.html
// https://code.google.com/p/android/issues/detail?id=18336
// Use reflection to call a private method available on some Samsung devices.
Integer value = -1;
Method m;
try {
m = SignalStrength.class.getMethod("getGsmSignalBar");
value = (Integer) m.invoke(signalStrength);
Log.d("Value signal Bar", "" + value);
} catch (NoSuchMethodException nsme) {
Log.d("Value signal Bar", "No such method...");
} catch (Exception e) {
Log.d("Value signal Bar", "Unexpected exception!");
}
int asu = signalStrength.getGsmSignalStrength();
if (asu == 99) {
if (value == 4) {
asu = 18;
} else if (value == 3) {
asu = 9;
} else if (value == 2) {
asu = 3;
} else if (value != 1) {
asu = 1;
}
}
return asu;
}