2014-06-17 37 views
1

基於LocationManager.NETWORK_PROVIDER的位置基於android將連接的單元ID發送到地理位置服務器。這需要一個積極的interent conncetion。查詢單元ID將返回存儲在服務器上的塔的大概位置。Android:基於單元ID的位置

locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); 
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, TWO_MINUTES, MIN_DISTANCE, mLocation); 
    Location current = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); 
    if(current != null) 
     Log.d("Location", "Lat: " + current.getLatitude() + ", Lon: " + current.getLongitude() + ", Acc: " + current.getAccuracy()); 

使用此代碼我可以從服務器獲取位置。不過,我想了解它做它的機制。

我一直在搜索android源代碼,系統發送請求到服務器獲取位置沒有任何運氣。

我在位置以及服務文件夾搜索框架。 Im將KitKat設備作爲KitKat與其融合提供商一起編碼簡化了這一過程。

任何幫助將不勝感激

薩赫勒

回答

0

的功能在谷歌實施發揮服務至極不是開源的,它需要一個互聯網連接。

一個Android應用程序可以通過

telephonyManager.listen(mListener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_CELL_INFO); 

得到的細胞信息的更新,其中的答案來自

PhoneStateListener mListener = new PhoneStateListener() { 
    @Override 
    public void onCellLocationChanged(android.telephony.CellLocation androidItem) { 
     .... 
    } 

    @Override 
    public void onCellInfoChanged(List<CellInfo> androidCellInfo) { 
     .... 
    } 
}; 

我DONOT知道谷歌playservices請問該位置的更新。也許他們有他們自己的位置管理器 - 執行

+0

好吧,讓位置的函數在googleplay庫中。非常感謝。 –