Skip to content
Snippets Groups Projects
Commit c26038ba authored by akwizgran's avatar akwizgran
Browse files

Don't crash if service is recreated by alarm.

parent 51eedd96
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,12 @@ 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);
setAlarm();
if (alarm == null) {
log.log("Service recreated by alarm");
setAlarm(alarmType);
} else {
setAlarm();
}
}
return START_NOT_STICKY; // Don't restart automatically if killed
}
......
......@@ -30,7 +30,7 @@
android:id="@+id/startServiceButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/start_service"
android:text="@string/apply_settings"
android:onClick="onClickStartServiceButton"/>
<ScrollView
......@@ -42,8 +42,7 @@
<TextView
android:id="@+id/outputTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ready"/>
android:layout_height="wrap_content"/>
</ScrollView>
......
<resources>
<string name="app_name">Snooze</string>
<string name="ongoing_notification_title">Snooze is running</string>
<string name="ongoing_notification_text">Touch to open</string>
<string name="use_permanent_wake_lock">Permanent wake lock</string>
<string name="use_foreground_service">Foreground service</string>
<string name="start_service">Start service</string>
<string name="ready">Ready</string>
<string-array name="alarm_types">
<item>Timer</item>
<item>ScheduledExecutorService</item>
......
<resources>
<string name="app_name">Snooze</string>
<string name="ongoing_notification_title">Snooze is running</string>
<string name="ongoing_notification_text">Touch to open</string>
<string name="use_permanent_wake_lock">Permanent wake lock</string>
<string name="use_foreground_service">Foreground service</string>
<string name="start_service">Start service</string>
<string name="ready">Ready</string>
<string-array name="alarm_types">
<item>Timer</item>
<item>ScheduledExecutorService</item>
......
......@@ -4,8 +4,7 @@
<string name="ongoing_notification_text">Touch to open</string>
<string name="use_permanent_wake_lock">Permanent wake lock</string>
<string name="use_foreground_service">Foreground service</string>
<string name="start_service">Start service</string>
<string name="ready">Ready</string>
<string name="apply_settings">Apply settings</string>
<string-array name="alarm_types">
<item>Timer</item>
<item>ScheduledExecutorService</item>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment