I have the above code and before the insert of try-catch I had this error at logcat
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
The problem was into the for loop for the List cellInfoList. Where exactly is the problem.
List<CellInfo> cellInfoList = tm.getAllCellInfo();
try {
for (final CellInfo info : cellInfoList) {
if (info instanceof CellInfoLte) {
final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
test1 = lte.getDbm();
//lte.getTimingAdvance();
test2 = identityLte.getMcc();
//identityLte.getMnc();
test3 = identityLte.getCi();
}
}
} catch (Exception e) {
Log.e(TAG, "Unable to obtain cell signal information", e);
}
Thank you