本文整理汇总了Java中android.telephony.CellInfoWcdma.getCellSignalStrength方法的典型用法代码示例。如果您正苦于以下问题:Java CellInfoWcdma.getCellSignalStrength方法的具体用法?Java CellInfoWcdma.getCellSignalStrength怎么用?Java CellInfoWcdma.getCellSignalStrength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.CellInfoWcdma
的用法示例。
在下文中一共展示了CellInfoWcdma.getCellSignalStrength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toCellularInfo
import android.telephony.CellInfoWcdma; //导入方法依赖的package包/类
private static CommonCellInfo toCellularInfo(CellInfoWcdma cellInfo) {
CommonCellInfo res = new CommonCellInfo();
CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();
CellSignalStrength signalStrength = cellInfo.getCellSignalStrength();
res.setType(WCDMA);
res.setCid(identityWcdma.getCid());
res.setLac(identityWcdma.getLac());
res.setMcc(identityWcdma.getMcc());
res.setMnc(identityWcdma.getMnc());
res.setDbm(valdiateDbm(signalStrength.getDbm()));
res.setLevel(signalStrength.getLevel());
return res;
}
示例2: cellInfoWCDMAJSON
import android.telephony.CellInfoWcdma; //导入方法依赖的package包/类
/**
* Converts CellInfoWcdma into JSON
* Some devices may not work correctly:
* - Reference 1: https://code.google.com/p/android/issues/detail?id=191492
* - Reference 2: http://stackoverflow.com/questions/17815062/cellidentitygsm-on-android
* @param cellInfo CellInfoWcdma
* @return JSON
*/
public static String cellInfoWCDMAJSON(CellInfoWcdma cellInfo, boolean returnSignalStrength){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) {
try {
json.put("provider", CELLINFO_PROVIDER);
json.put("type", WCDMA);
json.put("timestamp", calendar.getTimeInMillis());
final CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();
json.put("cid", identityWcdma.getCid());
json.put("lac", identityWcdma.getLac());
json.put("mcc", identityWcdma.getMcc());
json.put("mnc", identityWcdma.getMnc());
json.put("psc", identityWcdma.getPsc());
if (returnSignalStrength){
final JSONObject jsonSignalStrength = new JSONObject();
final CellSignalStrengthWcdma cellSignalStrengthWcdma = cellInfo.getCellSignalStrength();
jsonSignalStrength.put("asuLevel", cellSignalStrengthWcdma.getAsuLevel());
jsonSignalStrength.put("dbm", cellSignalStrengthWcdma.getDbm());
jsonSignalStrength.put("level", cellSignalStrengthWcdma.getLevel());
json.put("cellSignalStrengthWcdma", jsonSignalStrength);
}
}
catch(JSONException exc) {
logJSONException(exc);
}
}
return json.toString();
}