Unregistering LocationListener from within a BroadcastReceiver
<p>I'm trying to get a location-fix every time some specific "event" happens, say - a new SMS is received. Every time this event is broadcasted, i broadcast my own event, to be handled by the following class:</p>

<pre><code>    public class MyReceiver extends BroadcastReceiver implements LocationListener {

    LocationManager m_locationManager;

    @Override
    public void onReceive(Context context, Intent intent) {
        m_locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        Location lastKnownLocation = m_locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        m_locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this, Looper.getMainLooper());
    }

    public void onLocationChanged(Location location) {
        // TODO: some logic to handle location-change

        // Will this actually unregister the BroadcastReceiver even after it's destroyed, due to the Looper.getMainLooper()
        // running the callback?
        m_locationManager.removeUpdates(this);
    }

    // ... other LocationListener must-implement methods (with an empty body)
}
</code></pre>

<p>I'm well aware of the fact that the BroadcastReceiver may "die" before the first call to onLocationChanged() will occur, and therefore i've implemented the callback on the main-thread (using Looper.getMainLooper()), inspired by <a href="http://java-knowhow.blogspot.com/2011/05/android-locationmanager-from.html" rel="nofollow">this post</a>.
 It seem to work, as after calling removeUpdates(), the listener doesn't get called when location changes, still i see the GPS icon on the status bar long, long time after the un-registration occurs.
There are no other applications listening to GPS, no other instances of MyBroadcastReceiver active.
 Am i figuring the whole thing wrong here? can this be caused by a listener-leak, although it's seem to be successfully unregistered (at least in debug mode, where i see the removeUpdates() call is actually made).
Is there a chance that the GPS icon flashes even when there are no listeners active?</p>
