获取相邻小区中的Andr​​oid返回null [英] Get neighboring cell in Android returns null

查看:412
本文介绍了获取相邻小区中的Andr​​oid返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Android的相邻小区信息,但功能 getNeighboringCellInfo()总是返回null。

I'm trying to get the neighbouring cell info in Android but the function getNeighboringCellInfo() always return null.

我用下面的code:

protected void getCellInfo() {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    List<NeighboringCellInfo> neighborCells = telephonyManager.getNeighboringCellInfo();
    if (neighborCells == null) {
        OutUtils.debug("no neighbor cells");
    } else {
        ...
    }
}

上下文变量是服务类。

我的Andr​​oidManifest.xml许可

My AndroidManifest.xml permission

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

我试过有和没有启用使用2G网络选项中的Andr​​oid。

I tried with and without enabling the "Use 2G networks" option in Android.

你知道吗?谢谢

推荐答案

我想,也许你​​没有设置清单中的所有必要的权限。看看这里<一href="http://stackoverflow.com/questions/3868223/problem-with-neighboringcellinfo-cid-and-lac">Problem与NeighboringCellInfo,CID和LAC

I think, maybe you haven't set all necessary permissions in Manifest. look here Problem with NeighboringCellInfo, CID and LAC

如果你觉得你有他们,把清单中的问题,也请。

If you think you have them, put the manifest in the question, too, please.

这篇关于获取相邻小区中的Andr​​oid返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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