Li1369792 2018-09-22 13:42 采纳率: 0%
浏览 1252

Android开发中真机测试GsmCellLocation对象获取为空?

真机测试中GsmCellLocation对象获取为空

权限已经添加

SCell cell = new SCell();
    TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    //返回值MCC + MNC
    String operator = mTelephonyManager.getNetworkOperator();
    int mcc = Integer.parseInt(operator.substring(0, 3));
    int mnc = Integer.parseInt(operator.substring(3));

    // 中国移动和中国联通获取LAC、CID的方式
    GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();
    if (location != null) {
        Log.d("YES", "************OK!!************");
    }else if(location == null){
        Log.d("NO", "************NULL!!************");
    }

    int lac = location.getLac();
    int cellId = location.getCid();

以下是Android Studio的报错:
location为空。
对了,,在模拟器中运行是没有这个问题的。。
如果有路过的高手了解这个问题恳请告知我问题所在,谢谢!!
图片说明

  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2018-09-22 13:52
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题