Features
- All five prayer times displayed in a single view
- Live countdown to the next prayer, updated every minute
- Location display showing your configured city
- Hijri date displayed in the header
- Visual indicators showing which prayers have passed
- Tap to open the main app for full functionality
Widget appearance
The widget displays:Header section
- Left side: Location name and Hijri date
- Right side: Next prayer name and countdown (e.g., “Dhuhr in 2h 30m”)
Prayer times row
A horizontal row showing all five prayers:| Prayer | Display |
|---|---|
| Fajr | Name and time |
| Dhuhr | Name and time |
| Asr | Name and time |
| Maghrib | Name and time (shortened to “Mgrb”) |
| Isha | Name and time |
The widget automatically highlights the next prayer and dims prayers that have already passed for the day.
Adding the widget
Drag to home screen
Drag the widget to your desired location. The widget is a fixed size optimized for readability.
Live countdown feature
The widget displays a live countdown to the next prayer that updates approximately every minute.Countdown format
The countdown adapts based on time remaining:- More than 1 hour: Shows hours and minutes (e.g., “2h 30m”)
- Less than 1 hour: Shows minutes and seconds (e.g., “45m 12s”)
- Less than 1 minute: Shows only seconds (e.g., ”42s”)
Update mechanism
The countdown usesWidgetUpdateScheduler which schedules per-minute updates via AlarmManager:
Implementation details
Widget structure
The widget is implemented using Jetpack Glance composables:Widget states
The widget manages three states:Update lifecycle
The widget updates through two mechanisms:Periodic data updates
PrayerTimesWorker runs periodically to refresh prayer time data:
Countdown tick updates
WidgetTickReceiver updates the countdown display every minute:
Widget manifest registration
The widget is registered inAndroidManifest.xml:
Styling and theming
The widget uses these color resources:Visual states
- Active prayers: Shown in primary color
- Passed prayers: Shown in dimmed secondary color
- Next prayer: Highlighted with accent color
- Background: Rounded corners with 16dp radius
Interaction
Tapping anywhere on the widget launchesMainActivity via:
Battery optimization
The widget is designed for battery efficiency:- Uses
setInexactRepeating()instead of exact alarms for countdown updates - Allows the system to batch updates with other apps
- Periodic data updates run only when needed
- No continuous background processes
While countdown updates occur approximately every minute, the system may slightly delay them to optimize battery usage. This is normal Android behavior.
Troubleshooting
Widget shows “Tap to setup”
This indicates prayer times haven’t been calculated yet. Solution:- Open the Nimaz app
- Grant location permission if prompted
- Allow the app to calculate prayer times
- Return to home screen - widget will update automatically
Prayer times not updating
If times don’t refresh after midnight: Solution:- Check battery optimization settings for Nimaz
- Ensure background data is enabled
- Tap the widget to force a refresh
- If issue persists, remove and re-add the widget
Countdown stuck or not updating
The countdown may freeze if the system kills the update scheduler. Solution:- Remove battery optimization for Nimaz
- Restart your device
- Re-add the widget to reinitialize the update scheduler
Wrong location displayed
The widget shows your configured location from the app. Solution:- Open Nimaz app
- Go to Settings → Location
- Update your location
- Widget will reflect the change after next update
Related widgets
- Next prayer widget - Simpler widget showing only the upcoming prayer
- Prayer tracker widget - Track which prayers you’ve completed
- Hijri date widget - Display today’s Islamic date