List of usage examples for android.telephony CellSignalStrengthGsm 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 CellInfoGsm into JSON// w w w . jav a 2 s . c om * @param cellInfo CellInfoGsm * @return JSON */ public static String cellInfoGSMJSON(CellInfoGsm 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", GSM); json.put("timestamp", calendar.getTimeInMillis()); final CellIdentityGsm identityGsm = cellInfo.getCellIdentity(); json.put("cid", identityGsm.getCid()); json.put("lac", identityGsm.getLac()); json.put("mcc", identityGsm.getMcc()); json.put("mnc", identityGsm.getMnc()); if (returnSignalStrength) { final JSONObject jsonSignalStrength = new JSONObject(); final CellSignalStrengthGsm cellSignalStrengthGsm = cellInfo.getCellSignalStrength(); jsonSignalStrength.put("asuLevel", cellSignalStrengthGsm.getAsuLevel()); jsonSignalStrength.put("dbm", cellSignalStrengthGsm.getDbm()); jsonSignalStrength.put("level", cellSignalStrengthGsm.getLevel()); json.put("cellSignalStrengthGsm", jsonSignalStrength); } } catch (JSONException exc) { logJSONException(exc); } } return json.toString(); }