Search code examples
androidandroid-studiotelephony

Cannot resolve method 'getEarfcn' in 'CellIdentityLte'


TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
    CellInfo ci = tm.getAllCellInfo().get(0) ; // Registered Cell Tower

if (ci instanceof CellInfoGsm)  {
        ((CellInfoGsm)ci).getCellIdentity().getArfcn();
    } else if (ci instanceof CellInfoWcdma) {
        ((CellInfoWcdma)ci).getCellIdentity().getUarfcn();
    } else if (ci instanceof CellInfoLte) {
        ((CellInfoLte)ci).getCellIdentity().getEarfcn();
    }

Errors :

  1. Cannot resolve method 'getEarfcn' in 'CellIdentityLte'
  2. Cannot resolve method 'getArfcn' in 'CellIdentityGsm'
  3. Cannot resolve method 'getUarfcn' in 'CellIdentityWcdma'

Solution

  • Solved;

    setup sdkversion to 24 didn't make attention this was added in API 24.