Skip to content

Commit

Permalink
Intent with setprefercelltower will enable or disable GPS listener
Browse files Browse the repository at this point in the history
Closes #300
  • Loading branch information
mendhak committed Apr 4, 2015
1 parent 5d1044d commit 3b32b09
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;

public class GpsLoggingService extends Service {
private static NotificationManager notificationManager;
Expand Down Expand Up @@ -157,7 +157,16 @@ private void HandleIntent(Intent intent) {
if (bundle.get(IntentConstants.PREFER_CELLTOWER) != null) {
boolean preferCellTower = bundle.getBoolean(IntentConstants.PREFER_CELLTOWER);
tracer.debug("Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower));
prefs.edit().putBoolean("prefer_celltower", preferCellTower).apply();

List<String> listeners = Utilities.GetListeners();
if(preferCellTower){
listeners.remove(listeners.indexOf("gps"));
} else {
listeners.remove(listeners.indexOf("network"));
listeners.remove(listeners.indexOf("passive"));
}
Set<String> listenersSet = new HashSet<String>(listeners);
prefs.edit().putStringSet("listeners", listenersSet).apply();
needToStartGpsManager = true;
}

Expand Down

0 comments on commit 3b32b09

Please sign in to comment.