0

如何获得正确的频带和带宽值?,我按照官方文档使用下面的代码。

参考:getBands() - https://developer.android.com/reference/android/telephony/CellIdentityLte#getBands() 参考:getBandwidth() - https://developer.android.com/reference/android/telephony/CellIdentityLte #getBandwidth()

CellInfo cellInfo = telephonyManager.getAllCellInfo().get(0);
        
if (cellInfo instanceof CellInfoLte) 
{            
  CellIdentityLte cellIdentityLte = ((CellInfoLte) cellInfo).getCellIdentity();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
      band = cellIdentityLte.getBands();
  }
  bandwidth = cellIdentityLte.getBandwidth();
}

权限:

READ_PHONE_STATE, READ_PRECISE_PHONE_STATE, ACCESS_NETWORK_STATE, INTERNET etc.
4

0 回答 0