-1

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

Edward M
  • 83
  • 1
  • 9

1 Answers1

0

Eventually,the problem was from my device that is not let me to take these informations to fill up the array.In another smartphone it works fine. Thank you

Edward M
  • 83
  • 1
  • 9