KBootReceiver

BroadcastReceiver that runs registered BootTasks on device boot.

Declare in AndroidManifest.xml:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<receiver
android:name="dev.kindling.android.natif.KBootReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
</intent-filter>
</receiver>

Register tasks in your Application.onCreate before boot fires — i.e. always register on every app start, not just the first time:

// Application.onCreate
BackgroundHelper.addBootTask(
BootTask(
taskKey = "weekly-report",
rescheduleScheduled = BackgroundMode.WorkManagerScheduled(
uniqueName = "weekly-report",
dayOfWeek = DayOfWeek.FRIDAY,
hour = 19
)
)
)

// Or a simple one-shot on boot:
BackgroundHelper.addBootTask(
BootTask(
taskKey = "sync-on-boot",
mode = BackgroundMode.WorkManagerOnce(uniqueName = "sync-on-boot")
)
)

Note: LOCKED_BOOT_COMPLETED fires even before the user unlocks — only use it for tasks that don't need credential-encrypted storage.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val sentFromUid: Int

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onReceive(context: Context, intent: Intent)
Link copied to clipboard
open fun peekService(myContext: Context?, service: Intent?): IBinder?
Link copied to clipboard
fun setOrderedHint(isOrdered: Boolean)
Link copied to clipboard
fun setResult(code: Int, data: String?, extras: Bundle?)
Link copied to clipboard
fun setResultExtras(extras: Bundle?)