即时信号强度 [英] Instant signal strength

查看:106
本文介绍了即时信号强度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一种方法来衡量的Andr​​oid手机目前的信号强度,而不需要注册一个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。 <一href="http://stackoverflow.com/questions/2011543/android-why-are-methods-for-getting-neighboring-cell-signal-strengths-better-tha/3720676#3720676">Not只有上帝知道当 PhoneStateListener 将被触发;)

p.s. Not only God knows when PhoneStateListener will be triggered ;)

这篇关于即时信号强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆