From: Marius Gavrilescu Date: Fri, 5 Apr 2013 22:05:37 +0000 (+0300) Subject: Make location updates cancelable X-Git-Tag: 0.000_001~38 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=878b06d456f2f0c67c3e751301c77aecca16e0c4;p=fonbot.git Make location updates cancelable LocationManager instances are now got from the application context, so canceling always works. --- diff --git a/src/ro/ieval/fonbot/Heavy.java b/src/ro/ieval/fonbot/Heavy.java index 3249db8..2e379e0 100644 --- a/src/ro/ieval/fonbot/Heavy.java +++ b/src/ro/ieval/fonbot/Heavy.java @@ -939,7 +939,7 @@ final class Heavy { * @see LocationManager#requestLocationUpdates(String, long, float, LocationListener) */ public static void location(final Context context, final Address replyTo, final String provider,final long minTime,final float minDistance){ - final LocationManager man=(LocationManager) context.getSystemService(Context.LOCATION_SERVICE); + final LocationManager man=(LocationManager) context.getApplicationContext().getSystemService(Context.LOCATION_SERVICE); if(locationListener!=null) nolocation(context, toNonNull(Address.BLACKHOLE)); Utils.registerOngoing(context, toNonNull(OngoingEvent.LOCATION)); @@ -1049,7 +1049,7 @@ final class Heavy { */ public static void nolocation(final Context context, final Address replyTo){ Utils.unregisterOngoing(context, toNonNull(OngoingEvent.LOCATION)); - final LocationManager man=(LocationManager) context.getSystemService(Context.LOCATION_SERVICE); + final LocationManager man=(LocationManager) context.getApplicationContext().getSystemService(Context.LOCATION_SERVICE); man.removeUpdates(locationListener); locationListener=null; Utils.sendMessage(context, replyTo, no_longer_listening_for_location_updates);