List of usage examples for android.telephony CellSignalStrengthWcdma getLevel
@Override @IntRange(from = SIGNAL_STRENGTH_NONE_OR_UNKNOWN, to = SIGNAL_STRENGTH_GREAT) public int getLevel()
From source file:com.esri.cordova.geolocation.utils.JSONHelper.java
/** * Converts CellInfoWcdma into JSON//from w w w . ja v a2 s . c o m * 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(); }