简体   繁体   English

如何获得信号强度android?

[英]How to get signal strength android?

CellSignalStrength is the closest to what i need, but the problem i'm facing is that there is no constructor to use the class, and I tried to make a new class and extend it, it didn't work, the android documentation is good, without offering one small piece of code to follow, I don't know what to do. CellSignalStrength是最接近我需要的,但我面临的问题是没有使用该类的构造函数,我尝试创建一个新类并对其进行扩展,但没有用,android 文档很好,不提供一小段代码来遵循,我不知道该怎么办。

i'm using API 8, which doesn't support that class, what should I do ?我正在使用不支持该类的 API 8,我该怎么办?

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> all = telephonyManager.getAllCellInfo();
CellInfoGsm cellinfogsm = (CellInfoGsm) all.get(0);
CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm.getCellSignalStrength();
int strengthDbm = cellSignalStrengthGsm.getDbm();

should work fine for API 17+. API 17+ 应该可以正常工作。 I am not aware of any API to help <17, though.不过,我不知道有任何 API 可以帮助 <17。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM