Skip to content

Commit

Permalink
Merge pull request #1312 from garvankeeley/1311-network-prov-not-avail
Browse files Browse the repository at this point in the history
MapLocationListener: wrap requestLocUpdates to catch and ignore exceptions
  • Loading branch information
crankycoder committed Nov 28, 2014
2 parents 8fc7d0d + 35c9500 commit 67b4a5f
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.os.Bundle;
import android.widget.Toast;

import org.mozilla.mozstumbler.service.AppGlobals;
import org.mozilla.mozstumbler.service.stumblerthread.scanners.GPSScanner;

import java.lang.ref.WeakReference;
Expand Down Expand Up @@ -120,11 +121,16 @@ private void enableLocationListener(boolean isEnabled, LocationUpdateListener li
return;
}

if (isEnabled && !listener.mIsActive) {
mLocationManager.requestLocationUpdates(listener.mType, listener.mFreqMs, 0, listener);
} else if (!isEnabled && listener.mIsActive) {
mLocationManager.removeUpdates(listener);
try {
if (isEnabled && !listener.mIsActive) {
mLocationManager.requestLocationUpdates(listener.mType, listener.mFreqMs, 0, listener);
} else if (!isEnabled && listener.mIsActive) {
mLocationManager.removeUpdates(listener);
}
} catch (IllegalArgumentException ex) {
AppGlobals.guiLogError("enableLocationListener failed");
}

listener.mIsActive = isEnabled;
}

Expand Down

0 comments on commit 67b4a5f

Please sign in to comment.