问题描述
我需要找到一种方法来衡量的Android手机目前的信号强度,而不需要注册一个PhoneStateListener神知道,当它返回实际ASU。
I need to find a way to measure the current signal strength of Android phone, without the need to register a PhoneStateListener that God knows when it returns the actual asu.
是这样的:
int signal = getPhoneSignal();
任何帮助嘿?
any help plz?
谢谢!
推荐答案
如果你将不得不在Android源仔细看看,你会看到,在注册后 PhoneStateListener
,你将有即时通知:
If you will have a closer look on Android sources you will see that after registering PhoneStateListener
you will have instant notification:
public void listen(PhoneStateListener listener, int events) {
String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
try {
Boolean notifyNow = (getITelephony() != null);
mRegistry.listen(pkgForDebug, listener.callback, events, notifyNow);
} catch (RemoteException ex) {
// system process dead
}
}
所以,你可以创建自己的计时器,计时器更新注册新的侦听器和接收即时更新后删除它通过传递同一个侦听对象,并设置事件参数 LISTEN_NONE
我当然不能称之为最佳实践,但我能看到的唯一的选择是自己根据从的信号强度计算信号强度getNeighboringCellInfo()
。
Of course I can't call it best practice but the only alternative I can see is to calculate signal strength by yourself based on signal strengths from getNeighboringCellInfo()
.
P.S。 Not只有上帝知道当 PhoneStateListener
将被触发;)
p.s. Not only God knows when PhoneStateListener
will be triggered ;)
这篇关于即时信号强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!