Skip to content

Instantly share code, notes, and snippets.

@LloydBlv
Created May 13, 2025 08:58
Show Gist options
  • Save LloydBlv/6adc6b265bf08ec14faa4cdebe46ae1d to your computer and use it in GitHub Desktop.
Save LloydBlv/6adc6b265bf08ec14faa4cdebe46ae1d to your computer and use it in GitHub Desktop.
class BootCompletedReceiver : BroadcastReceiver() {
private val rescheduler: TaskRescheduler by inject()
override fun onReceive(context: Context, intent: Intent?) {
if (intent?.action == Intent.ACTION_BOOT_COMPLETED) {
rescheduler.reschedule()
}
}
}
interface TaskRescheduler {
fun reschedule()
}
class DefaultTaskRescheduler @Inject constructor(
private val workManager: WorkManager
) : TaskRescheduler {
override fun reschedule() {
workManager.enqueue(...) // clean and testable
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment