如何获得手机服务信号强度的Andr​​oid

如何获得手机服务信号强度的Andr​​oid

本文介绍了如何获得手机服务信号强度的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个非常简单的Andr​​oid应用程序,检查当前单元格的信号强度。到目前为止,我只发现了一些所谓的 getNeighboringCellInfo(),但我真的不知道,如果它包括当前单元格。

如何获取当前单元格的信号强度在Android的?

确实 getNeighborCellInfo()获取当前单元格?它似乎并不像它的基础上,我已经能够得到它的结果。这是我目前的code:

 名单,其中,NeighboringCellInfo> N = tm.getNeighboringCellInfo();

//构造字符串
字符串s =;
INT RSS = 0;
INT CID = 0;
对于(NeighboringCellInfo NCI:N)
{
    CID = nci.getCid();
    RSS = -113 + 2 * nci.getRssi();
    S + =小区ID:+ Integer.toString(CID)+信号功率(dBm):+
            Integer.toString(RSS)+\ N的;
}

mainText.setText(多个);
 

解决方案

创建一个PhoneStateListener并处理onSignalStrengthChanged回调。当你的应用程序初始化,它应该给你一个初始通知。这是在1.x的在2.x中,有一个开放的问题这一点。

I am trying to write a very simple Android application that checks the signal strength of the current cell. So far, I have only found something called getNeighboringCellInfo(), but I'm not really sure if that includes the current cell.

How do I get the CURRENT cell signal strength in Android?

Does getNeighborCellInfo() get the current cell? It doesn't seem like it based on the results that I have been able to get with it. Here's my current code:

List<NeighboringCellInfo> n = tm.getNeighboringCellInfo();

//Construct the string
String s = "";
int rss = 0;
int cid = 0;
for (NeighboringCellInfo nci : n)
{
    cid = nci.getCid();
    rss = -113 + 2*nci.getRssi();
    s += "Cell ID: " + Integer.toString(cid) + "     Signal Power (dBm): " +
            Integer.toString(rss) + "\n";
}

mainText.setText(s);
解决方案

create a PhoneStateListener and handle the onSignalStrengthChanged callback. When your app is initialized, it should give you an initial notification. This is in 1.x. in 2.x, there's an open issue about this.

这篇关于如何获得手机服务信号强度的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:36