2017-07-03 52 views
-2

無法使用位於較低版本的設備(如棒棒糖和糖果豆設備)的融合位置提供商客戶端以離線模式獲取位置。安卓離線位置獲取

+1

歡迎堆棧溢出!請編輯您的問題並提供[最小,完整和可驗證的示例](https://stackoverflow.com/help/mcve)您的問題 –

回答

0

您可以從手機SIM中獲取GPS位置,GsmCellLocation會爲您提供最近移動塔的座標。

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 


TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); 
    GsmCellLocation gsmCellLocation = (GsmCellLocation)telephonyManager.getCellLocation(); 

    int cell_id = gsmCellLocation.getCid(); 
    int cell_lac = gsmCellLocation.getLac(); 

    Log.d("CellLocation", gsmCellLocation.toString()); 
    Log.d("GSM Location Code", String.valueOf(cell_lac)); 

:)