views:

14

answers:

0

Hey guys,

I've a really strange problem,

I'm getting location updates with a GPS Listener, everything works fine. I also watch this listener with a timeout, if the timeout gets exeeded, it stops the thread, removesLocation updates everything works...

BUT, if there's no Internet Connection available, an exeption gets called, it should stop the thread, remove the updates (the finally case of the thread gets called, BUT, onLocationChanged gets called serverl times again.

code of the Exception:

catch (Exception e) {
        e.printStackTrace();
        //set some text here
        Main.mLocationRequestInProgress_ = false;
        // stop thread
        Main.mTimeoutWatcher_ = null;
        // don't try to get more location updates
        Main.mLocationManager_.removeUpdates(Main.mLocationListener_);
        // show dialog problem on gps connect
        Utils.showNotificationMessage(mContext_, R.string.msgNoAddressReceived);
    }

the first time after this code, the finall case is being executed (nearly the same code as here..)

but afterwards the onLocationChanged Code gets executed several more times (3-4) until an memory error occurs.

I've made a workaround, asking if the thread is null, if no, get location updates, else just skip it...

It works, but i'm wondering why

Main.mLocationManager_.removeUpdates(Main.mLocationListener_);

has no effect at all.

thanks a lot, mike