2011-09-16 15 views
0

如何使用curruent來定位緯度經常更新

我是android新手。我想將緯度經度發送給定期更新的網絡服務,時間間隔爲15分鐘。即使我的設備處於精彩模式,即使我的應用程序未處於活動狀態。即使手機長時間不移動,即使用戶移動速度很快。提前致謝。

+0

我想我涵蓋整個思考你需要什麼。 – user370305

回答

1

這裏有你需要的;)

http://developer.android.com/guide/topics/location/obtaining-user-location.html

這行代碼上的頁面設置更新率。

// Register the listener with the Location Manager to receive location updates 
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); 

這裏是它如何工作

http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String, long, float, android.app.PendingIntent) 

但切記要停止的位置更新,不需要他們的時候索姆更多的信息,它是在電池重

1

OK,

1.Lets start from the first, "periodically update at time interval of 15 minute" 
->for this we already suggest you to use service and timer or alarm manager. 

2. "Even if my device is in spleep mode". 
-> For this you prevent to going your device in sleep mode for that you can use android's WAKE_LOCK. 

3. "Even if my application is not active". 
-> I think for this, you can start a service at the device boot time, and it is countinuesly going to run.. 

4. "Even if phone is not moving for long period.Even if user is moving fast". 
-> for this from service save your lat,long at every 15 minutes and also check whether 
    location is updated or not if updated then just update your lat,long also, and then just 
    send the lat, long for every 15 minutes. 

希望大家能夠理解,謝謝,

+0

非常感謝。 – Manisha

+0

嗨,我可以知道如何更新當前活動的地圖視圖與最新的地點,這是由「服務」根據您的上述答案檢索。 –