2014-05-17 29 views
0

如何使用單元塔檢索我的位置?當GPS和Wifi關閉時。使用單元塔的Android位置

我知道我可以retrevive塔的cellID,但我怎麼能映射它獲取我的當前位置的緯度和經度?

我不在乎它是否不準確的位置。

我發現了一些片段,但似乎使用wifi。

+0

您只能從手機信號塔中找到CellId和位置區號(LAC)。通過使用這些值,您可以在互聯網的幫助下找到經度和緯度。 – Andrain

回答

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

    int cellid= cellLocation.getCid(); 
    int celllac = cellLocation.getLac(); 

Log.d("CellLocation", cellLocation.toString()); 
Log.d("GSM CELL ID", String.valueOf(cellid)); 
Log.d("GSM Location Code", String.valueOf(celllac)); 

確保您在清單中擁有這些權限。

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

如果你真的想真正的位置使用HttpClient的或有點查詢http://www.google.com/glm/mmap與小區id和LAC。例子在這裏列出。 http://www.anddev.org/poor_mans_gps_-celltowerid-_location_area_code_-lookup-t257.html

+0

謝謝,它的工作! –