位置关闭时,getCellLocation返回null

时间:2019-06-11 14:40:27

标签: android location telephonymanager android-gps

对于使用BTS跟踪设备,我需要CID和Lac。在诸如Asus和Huawei之类的设备中,当location(gps)关闭时,无法跟踪所有这些方法并返回null。

    /** Current Location Area Code */
    int mCurLAC = 0;
    /** Current Location Cell ID */
    int mCurCID = 0;


       TelephonyManager mTelephonyManager = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);

       GsmCellLocation gsmCellLocation = (GsmCellLocation) mTelephonyManager.getCellLocation();

       CellLocation cellLocation = mTelephonyManager.getCellLocation();
       List<NeighboringCellInfo> mNeighboringCellInfo = mTelephonyManager.getNeighboringCellInfo();
       List<CellInfo> allCellInfo = mTelephonyManager.getAllCellInfo();
       mCurCID = gsmCellLocation.getCid();
       mCurLAC = gsmCellLocation.getLac();

gsmCellLocation返回null

mNeighboringCellInfo返回null

allCellInfo返回null

cellLocation返回null

关闭GPS后如何获取当前位置?

0 个答案:

没有答案
相关问题