2013-07-17 91 views
0

是否有可能通過「GPS」在改變其像3-4英尺的非常短距離的位置後獲得用戶的精確緯度和經度。通過GPS在Android上查找當前位置

其實我已經在android中創建了一個應用程序,它給了我一個用戶的經度和緯度,但它改變了它在用戶的同一個點或位置上的值。

請幫我解決這個問題。 在此先感謝。

+0

請參閱[here](http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/) –

回答

0

我的經驗說,這取決於手機/設備使用的是,如果你的設備支持AGPS然後讓GPS座標會更容易和快速(沒有相關的您編碼技巧,因爲您將使用android SDK)。普通的GPS也會返回準確的數據,嘗試從谷歌播放下載Savaari應用程序,它的作用就像魅力,你的第二個問題是可以在特定的時間或距離間隔後獲得座標,當你註冊你的列表程序時,你必須提供時間和距離(以米爲單位)之後,您想要接收GPS值。

看看這個片斷: -

public void startReadingGPS(int readAfterMinimumTime, int readAfterMinimumDistance){ 
     locationManager = (LocationManager)mContext.getSystemService(Context.LOCATION_SERVICE); 
     locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, readAfterMinimumTime, readAfterMinimumDistance, this); 
    } 

公共無效requestLocationUpdates使用指定供應商(字符串提供商,長minTime,浮minDistance纔會,LocationListener的偵聽器) 在API級別1 註冊位置更新,並待決意圖。

有關如何使用此方法的更多詳細信息,請參閱requestLocationUpdates(long,float,Criteria,PendingIntent)。

參數 提供商的提供商與的名稱登記位置更新之間 minTime最小時間間隔,以毫秒爲單位的位置更新之間 minDistance纔會最小距離,以米爲單位 聽者LocationListener的其onLocationChanged(位置)方法將被稱爲爲每個位置更新

+0

欣賞您的答案,但我的另一個問題是,我將永遠不會改變位置,但GPS將不斷改變經緯度。請建議如何將它穩定在同一位置。 – AKber

+0

在你的位置監聽器中添加8到10米的變化實際上在Android GPS的情況下它的準確度約爲8米,這意味着即使你將手機放在一個地方,它仍然會改變座標我的拍攝將會增加10米後的GPS讀數, 祝一切順利 ! –

0

,你應該在你的活動實施LocationListener的

private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters 

     // The minimum time between updates in milliseconds 


     private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute 


      boolean isGPSEnabled = false; 

       LocationManager locationManager = (LocationManager) yourapplicationcontext 
             .getSystemService(LOCATION_SERVICE); 

           // getting GPS status 
           isGPSEnabled = locationManager 
             .isProviderEnabled(LocationManager.GPS_PROVIDER); 
      if (isGPSEnabled) { 
          if (location == null) { 
           locationManager.requestLocationUpdates(
             LocationManager.GPS_PROVIDER, 
             MIN_TIME_BW_UPDATES, 
             MIN_DISTANCE_CHANGE_FOR_UPDATES, this); 
           Log.d("GPS Enabled", "GPS Enabled"); 
           if (locationManager != null) { 
            location = locationManager 
              .getLastKnownLocation(LocationManager.GPS_PROVIDER); 
            if (location != null) { 
             latitude = location.getLatitude(); 
             longitude = location.getLongitude(); 
            } 
           } 
          } 
         } 
//Add this permission 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.INTERNET" />