package com.local.ktv import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.util.Log class BootReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent?) { if (intent?.action != Intent.ACTION_BOOT_COMPLETED) return runCatching { context.startActivity( Intent(context, MainActivity::class.java) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ) }.onFailure { Log.e(TAG, "Unable to launch KTV after boot", it) } } private companion object { const val TAG = "BootReceiver" } }