LocationService.java
i moved the broadcastLocation() call to onDestroy(), and replace all previous calls with kstopSelf(mStartId);
This commit is contained in:
@@ -53,7 +53,7 @@ public class LocationService extends Service implements LocationListener {
|
||||
private Runnable mFailSafe = new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
broadcastLocation();
|
||||
stopSelf(mStartId);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -94,7 +94,6 @@ public class LocationService extends Service implements LocationListener {
|
||||
locationUpdate.setAction(LocationReceiver.ACTION_UPDATE);
|
||||
locationUpdate.putExtra(LocationReceiver.LOCATION_PARCEL, mLocation);
|
||||
sendBroadcast(locationUpdate);
|
||||
stopSelf(mStartId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +147,7 @@ public class LocationService extends Service implements LocationListener {
|
||||
*/
|
||||
@Override
|
||||
public void onDestroy(){
|
||||
broadcastLocation();
|
||||
mLocationManager.removeUpdates(this);
|
||||
mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);
|
||||
if(mWakeLock.isHeld())
|
||||
@@ -165,7 +165,7 @@ public class LocationService extends Service implements LocationListener {
|
||||
// Log.d(TAG, "got location +- "+ location.getAccuracy() +"m");
|
||||
mLocation = location;
|
||||
if(location.getAccuracy() <= DESIRED_ACCURACY){
|
||||
broadcastLocation();
|
||||
stopSelf(mStartId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user