if you're still struggling with the problem, this is the method I'm using:
//permission check
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions((Activity)this,new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},1);
String list = ""; //I'm just adding everything to a string to display, but you can do whatever
//get cell info
TelephonyManager tel = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> infos = tel.getAllCellInfo();
for (int i = 0; i<infos.size(); ++i)
{
try {
CellInfo info = infos.get(i);
if (info instanceof CellInfoGsm) //if GSM connection
{
list += "Site_"+i + "\r\n";
list += "Registered: " + info.isRegistered() + "\r\n";
CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
list += "cellID: "+ identityGsm.getCid() + "\r\n";
list += "dBm: " + gsm.getDbm() + "\r\n\r\n";
//call whatever you want from gsm / identitydGsm
}
else if (info instanceof CellInfoLte) //if LTE connection
{
list += "Site_"+i + "\r\n";
list += "Registered: " + info.isRegistered() + "\r\n";
CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
//call whatever you want from lte / identityLte
}
else if (info instanceof CellInfoWcdma) //if wcdma connection
{
CellSignalStrengthWcdma wcdmaS = ((CellInfoWcdma) info).getCellSignalStrength();
CellIdentityWcdma wcdmaid = ((CellInfoWcdma)info).getCellIdentity();
list += "Site_"+i + "\r\n";
list += "Registered: " + info.isRegistered() + "\r\n";
//call whatever you want from wcdmaS / wcdmaid
}
} catch (Exception ex) {
Log.i("neighboring error 2: " ,ex.getMessage());
}
}
Log.i("Info display", list); //display everything.
And while we're busy, just a heads up, the LTE parsing is all screwy (you will see if you do getCi(), getTac() etc. ), so I wrote my own parsing class, and posted my answer here.
Hede of warning though, when you start to see that your neighboring cell info is totally wrong... (the problem that I'm currently at), this dilemma is also posted here. Good luck, and let me know if this part is not a issue for you