Agent thinks it fixed the crash on SDK36 and lack of interval counting down on SDK24.

This commit is contained in:
me committed 2026-11-08 19:38:16 -07:00
1 parent 432a1394b9
commit 9ff779b26c
2 files changed
+7 -2

No files matched your search

@@ -389,7 +389,8 @@ public class MainActivity extends AppCompatActivity {
// Delegate countdown logic to ForegroundService to survive Doze mode on SDK 36+ // Delegate countdown logic to ForegroundService to survive Doze mode on SDK 36+
Intent svcIntent = new Intent(this, TimerForegroundService.class); Intent svcIntent = new Intent(this, TimerForegroundService.class);
svcIntent.setAction(Alert.ACTION_TIMER); svcIntent.setAction(Alert.ACTION_TIMER);
svcIntent.putExtra(TimerForegroundService.EXTRA_INTERVAL_MS, longLoopInterval); // Pass the calculated `interval` (which includes the 60s fallback if user entered nothing)
svcIntent.putExtra(TimerForegroundService.EXTRA_INTERVAL_MS, interval);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(svcIntent); startForegroundService(svcIntent);
} else { } else {
@@ -703,7 +704,8 @@ public class MainActivity extends AppCompatActivity {
syncVolume(); syncVolume();
// Register receiver to get live updates from ForegroundService while app is visible // Register receiver to get live updates from ForegroundService while app is visible
registerReceiver(timerUpdateReceiver, new IntentFilter(TimerForegroundService.class.getName() + ".UPDATE")); // RECEIVER_NOT_EXPORTED (0x00010000) is required on Android 13+ for local broadcasts
registerReceiver(timerUpdateReceiver, new IntentFilter(TimerForegroundService.class.getName() + ".UPDATE"), 0x00010000);
if (DEBUG) Log.d(tag, "Finished"); if (DEBUG) Log.d(tag, "Finished");
} }
@@ -64,6 +64,9 @@ public class TimerForegroundService extends Service {
if (newInterval > 0) { if (newInterval > 0) {
loopIntervalMs = newInterval; loopIntervalMs = newInterval;
endTimeMillis = System.currentTimeMillis() + loopIntervalMs; endTimeMillis = System.currentTimeMillis() + loopIntervalMs;
tick(); // Start the countdown immediately when the service is launched
} else {
Log.w(TAG, "Received start command without a valid positive interval.");
} }
return START_STICKY; return START_STICKY;