Commit b6a2e78c authored by akwizgran's avatar akwizgran

Don't resume network connection and alarms if service is recreated.

parent c187f9e4
......@@ -32,7 +32,7 @@ public class LogFragment extends Fragment implements LogListener {
View layout = inflater.inflate(R.layout.fragment_log, container, false);
outputScrollView = (ScrollView) layout.findViewById(R.id.outputScrollView);
outputTextView = (TextView) layout.findViewById(R.id.outputTextView);
(layout.findViewById(R.id.clearLogButton)).setOnClickListener(new OnClickListener() {
layout.findViewById(R.id.clearLogButton).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onClickClearLogButton();
......
......@@ -36,7 +36,7 @@ public class SnoozeService extends Service {
private WifiManager.WifiLock wifiLock = null;
private NetworkClient networkClient = null;
private Alarm alarm = null;
private int alarmIntervalMs = 60 * 1000, keepaliveIntervalMs = 60 * 1000;
private int alarmIntervalMs, keepaliveIntervalMs;
private volatile Logger log = null;
......@@ -74,13 +74,8 @@ public class SnoozeService extends Service {
} else if (ACTION_ALARM.equals(i.getAction())) {
AlarmType alarmType = AlarmType.valueOf(i.getStringExtra(EXTRA_ALARM_TYPE));
log.log("Alarm " + alarmType);
if (alarm == null) {
log.log("Service recreated by alarm");
startNetworkThread();
setAlarm(alarmType);
} else {
setAlarm();
}
if (alarm == null) log.log("Service recreated by alarm");
else setAlarm();
}
return START_NOT_STICKY; // Don't restart automatically if killed
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment