LocationService.java

i moved the broadcastLocation() call to onDestroy(), and replace all previous calls with kstopSelf(mStartId);
This commit is contained in:
2011-01-31 17:04:56 +00:00
parent 1e5667d018
commit 4c624a34e3

View File

@@ -53,7 +53,7 @@ public class LocationService extends Service implements LocationListener {
private Runnable mFailSafe = new Runnable() { private Runnable mFailSafe = new Runnable() {
@Override @Override
public void run(){ public void run(){
broadcastLocation(); stopSelf(mStartId);
} }
}; };
@@ -94,7 +94,6 @@ public class LocationService extends Service implements LocationListener {
locationUpdate.setAction(LocationReceiver.ACTION_UPDATE); locationUpdate.setAction(LocationReceiver.ACTION_UPDATE);
locationUpdate.putExtra(LocationReceiver.LOCATION_PARCEL, mLocation); locationUpdate.putExtra(LocationReceiver.LOCATION_PARCEL, mLocation);
sendBroadcast(locationUpdate); sendBroadcast(locationUpdate);
stopSelf(mStartId);
} }
} }
@@ -148,6 +147,7 @@ public class LocationService extends Service implements LocationListener {
*/ */
@Override @Override
public void onDestroy(){ public void onDestroy(){
broadcastLocation();
mLocationManager.removeUpdates(this); mLocationManager.removeUpdates(this);
mNotificationManager.cancel(SIMPLE_NOTFICATION_ID); mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);
if(mWakeLock.isHeld()) if(mWakeLock.isHeld())
@@ -165,7 +165,7 @@ public class LocationService extends Service implements LocationListener {
// Log.d(TAG, "got location +- "+ location.getAccuracy() +"m"); // Log.d(TAG, "got location +- "+ location.getAccuracy() +"m");
mLocation = location; mLocation = location;
if(location.getAccuracy() <= DESIRED_ACCURACY){ if(location.getAccuracy() <= DESIRED_ACCURACY){
broadcastLocation(); stopSelf(mStartId);
} }
} }