且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获得LTE信号强度的Andr​​oid?

更新时间:2023-02-26 21:35:17

为了解决这个问题,我创建的 GitHub上。在我过去的经验,有些设备运行Android ICS 4.0及以上有一个 getLevel SignalStrength 方法,返回由一个整数0 - 4报告的信号强度。在一些其他的LTE设备(我不相信HTC霹雳),有喜欢 getLteCqi getLteRsrp getLteRsrq $>和 getLteRssnr ,我将离开你来决定如何使用这些值来计算信号强度。最后,我发现,在某些设备上(我相信HTC霹雳)的LTE信号的强度其实是与报道标示GSM信号强度的方法!它的疯狂,但却是事实。随意下载信号强度检测,并检查了设备上的结果和/或修改code是必要的。

In order to solve this question I created an application called Signal Strength Detector and with source code on GitHub. In my past experience, some devices running Android ICS 4.0 and up have a getLevel method on SignalStrength that returns an integer from 0 - 4 reporting the signal strength. On some other LTE devices (I do not believe the HTC Thunderbolt), there are some methods like getLteCqi getLteRsrp getLteRsrq and getLteRssnr which I will leave to you to determine how to use these values to calculate a signal strength. Finally, I found that on some devices (I believe the HTC Thunderbolt) the LTE signal strength is actually reported with the methods labelled for GSM signal strength! It's crazy, but true. Feel free to download Signal Strength Detector and check out the results on your device and/ or modify code as necessary.

作为一个方面说明,您将需要使用反射来访问这些方法,再一次,我将离开你来决定如何***地实现这一点。这是相当简单的,但你需要做大量的try-catch来确定方法为present,有时 setAccessible(真)只是忽略任何问题与私有方法。

As a side note, you will need to use Reflection to access these methods, again which I will leave to you to determine how to best implement this. It's fairly simple, but you need to do a lot of try-catch to determine if the method is present, and sometimes setAccessible(true) just to ignore any issues with private methods.

希望这有助于!