Created
May 13, 2025 08:58
-
-
Save LloydBlv/6adc6b265bf08ec14faa4cdebe46ae1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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