Here is what I have done:
protected class SignalStrengthListener extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(android.telephony.SignalStrength signalStrength) {
tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
ltestr = signalStrength.toString();
parts = ltestr.split(" ");
try {
cellInfoList = tm.getAllCellInfo();
for (CellInfo cellInfo : cellInfoList) {
if (cellInfo instanceof CellInfoLte) {
// cast to CellInfoLte and call all the CellInfoLte methods you need
// Gets the LTE PCI: (returns Physical Cell Id 0..503, Integer.MAX_VALUE if unknown)
cellPci = ((CellInfoLte) cellInfo).getCellIdentity().getPci();
}
}
} catch (Exception e) {
Log.d("SignalStrength", "Exception: " + e.getMessage());
}
super.onSignalStrengthsChanged(signalStrength);
}
}
Then I can print the parts
array element that I need. Here I am getting the PCI. Then just for a quick check print it with Log.d("TAG", "PCI is " + cellPci);
and watch for it in logcat.
You can check out my app that gets LTE RSRP, RSRQ, PCI, etc. at my github:
https://github.com/parksjg/IndoorLTE3a