after seeing that question and the answers (thanks by the way) I wrote this code wich is pretty much the same as in the answers:
try {
List<CellInfo> cellInfoList = telephonyManager.getAllCellInfo();
for (CellInfo cellInfo : cellInfoList) {
if (cellInfo instanceof CellInfoGsm) {
CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
CellIdentityGsm cellIdentity = cellInfoGsm.getCellIdentity();
final CellSignalStrengthGsm gsm = ((CellInfoGsm) cellInfo).getCellSignalStrength();
rsrpValue = gsm.getDbm();
pciValue = cellIdentity.getCid();
} else if (cellInfo instanceof CellInfoCdma) {
CellInfoCdma cellInfoCdma = (CellInfoCdma) cellInfo;
CellIdentityCdma cellIdentity = cellInfoCdma.getCellIdentity();
pciValue = cellIdentity.getBasestationId();
} else if (cellInfo instanceof CellInfoLte){
CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
CellIdentityLte cellIdentity = cellInfoLte.getCellIdentity();
pciValue = cellIdentity.getPci();
} else {
throw new Exception("Unknown type of cell signal!");
}
}
} catch (Exception e) {
Log.e(TAG, "Unable to obtain cell signal information", e);
}
But when I display rsrpValue or pciValue for GSM, I always get the maximum integer value (2147483647). I tried this on a phone with the API 17. Is there something wrong in my code?
Thanks