Android:为什么获取邻近小区信号强度的方法比获取当前小区信号强度的方法更好?
我正在编写一个收集手机信号强度的 Android 应用程序。我在获取“当前”小区信号强度时遇到问题,但在获取“邻近”小区信号强度时没有任何问题。
为了获取当前的手机信号强度,我创建了一个 PhoneStateListener 并实现了 onSignalStrengthChanged 回调。它有效,但不是很好。信号强度似乎几乎没有变化,分辨率也跳到只有几个数字。我会接受信号强度硬件的分辨率很粗糙的答案,但是当我使用 TelephonyManager 的 getNeighboringCellInfo() 方法时,它的工作效果要好得多。来自相邻小区的信号强度读数经常变化,并且它们具有更好的分辨率。
那么,如何以与获取相邻小区信号强度相同的方式获取当前小区信号强度呢?我觉得很奇怪的是,相邻单元格的功能比当前单元格更好。我在这里错过了什么吗?
如果可能的话,我还想直接调用电话管理器中的方法来获取当前的小区强度,而不是监听器。如果有人知道怎么做,请告诉我。谢谢。
I'm writing an android application that collects cell signal strengths. I am having trouble getting the "current" cell signal strength, but I don't have any problem getting the "neighboring" cell signal strengths.
To get the current cell signal strength, I created a PhoneStateListener and implemented the onSignalStrengthChanged callback. It works, but not very well. It seems like the signal strength hardly ever changes, and resolution jumps to only a few numbers. I would accept the answer that the resolution of the signal strength hardware is coarse, but when I use the TelephonyManager's getNeighboringCellInfo() method, it works much better. The signal strength readings from neighboring cells change frequently, and they have much better resolution.
So, how can I get the current cell signal strength in the same way that I am getting the neighboring cell strengths? It seems odd to me that the functionality of the neighboring cells is better than the current cell. Am I missing something here?
I would also like to directly call a method from the telephony manager to get current cell strength, as opposed to a listener, if possible. If anyone knows how, please let me know. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基于 Android 1.5 源 (BatteryStatsImpl.java),仅当信号在以下状态之间发生变化时才会发送通知:
因此,在您的情况下,信号强度在同一范围内变化,并且您不会收到通知。
我想这样做是为了节省电池寿命。
Based on Android 1.5 sources (BatteryStatsImpl.java) notification is being sent only if signal changes between following states:
So in your case signal strength changes within the same range and you don't receive notifications.
I guess it is done this way to save battery life.
我认为这种方法效果不是很好,因为正如 javadoc 中所写,
onSignalStrengthChanged()
自 api 2.0 起已弃用,并由onSignalStrengthsChanged()
取代(注意“s”),但不幸的是此方法是私有的!有一个关于此的未解决的问题,谷歌似乎已经由于未知原因删除了该方法(可能是因为它不像您所注意到的那样运行良好),并且它将在下一个 sdk 版本中提供。
您只需要耐心等待并在此处投票即可加快速度开发流程!
I think this method is not working very well because as written in the javadoc,
onSignalStrengthChanged()
is deprecated since api 2.0, and replaced byonSignalStrengthsChanged()
(note the "s"), but unfortunatly this method is private !There is an open issue about that, it seems google has removed the method for unknow reason (maybe because its not working well as you have noticed it), and it will be available in a next sdk release.
You just have to be patient then and vote here to speed up dev process !