0
我開發了一個android應用程序,每10秒使用GPS的當前位置,並使用套接字將其發送到服務器。爲了實現這一點,我使用postDelayed方法來獲取當前位置並將其發送到服務器。Android跟蹤應用程序導致設備過熱
myRunnable = new Runnable() {
@Override
public void run() {
Location mCurrentLocation =getCurrentLocation();
if(mCurrentLocation != null)
sendCurrentLocationToServer(mCurrentLocation);
Handler.postDelayed(this, 10000);
}};
public Location getCurrentLocation(){
Location currentLocation = myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
return currentLocation;
}
但是這個代碼使設備過熱,並迅速消耗電池,有另一種方式來達到同樣的效果,降低過熱?
謝謝