summaryrefslogtreecommitdiff
path: root/app/src/main/AndroidManifest.xml
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-08-22 01:08:22 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-08-22 01:08:22 +0000
commit7f324168464934d711953dc748fbc7c65eb88f4b (patch)
tree1bac6e3957ceca6736083dc4c1684c1d67941305 /app/src/main/AndroidManifest.xml
parent78bc7b3c48eae1b68d3f35c81ea2b959d8136477 (diff)
Add a 5am morning-fetch alarm so articles are fresh before you open the app
FeedFetchWorker's periodic 60-minute WorkManager job can (and does) get silently deferred for hours by Doze on an idle overnight device. An exact alarm (setExactAndAllowWhileIdle) wakes the device at a fixed 5am to run a fetch, without requesting the much broader "ignore battery optimizations" exemption -- battery optimization stays on otherwise, just this one daily wake-up. Android 12+ requires a one-time user grant for exact alarms (no in-app permission dialog); MainActivity requests it via Settings if not already granted, tracked across rotation via savedInstanceState so a config change doesn't re-trigger the Settings screen. The alarm also gets re-armed on BOOT_COMPLETED, since AlarmManager alarms don't survive a device restart on their own.
Diffstat (limited to 'app/src/main/AndroidManifest.xml')
-rw-r--r--app/src/main/AndroidManifest.xml19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b5b3532..a1053e3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,12 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <!-- For the 5am morning-fetch alarm (MorningFetchReceiver): lets it wake the device
+ at an exact time even under Doze, without the much broader "ignore battery
+ optimizations" exemption (user explicitly wants battery optimization left on
+ otherwise). Android 12+ requires the user grant this once via Settings; MainActivity
+ prompts for it if not already granted. -->
+ <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<application
android:label="@string/app_name"
@@ -40,5 +46,18 @@
</intent-filter>
</activity>
+ <!--
+ Fires the 5am morning fetch (exact alarm, set up by MorningFetchReceiver.scheduleNext,
+ called from MainActivity). Also re-arms that alarm after a reboot: an exact alarm
+ set via AlarmManager does NOT survive a device restart on its own.
+ -->
+ <receiver
+ android:name=".work.MorningFetchReceiver"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
+
</application>
</manifest>