From adb6a4fd9ec3a23c04d5e4c2ce799448237915c4 Mon Sep 17 00:00:00 2001 From: JustZvan Date: Fri, 6 Feb 2026 13:38:36 +0100 Subject: feat: initial commit --- app/src/main/java/sh/lajo/buddy/BootReceiver.kt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/src/main/java/sh/lajo/buddy/BootReceiver.kt (limited to 'app/src/main/java/sh/lajo/buddy/BootReceiver.kt') diff --git a/app/src/main/java/sh/lajo/buddy/BootReceiver.kt b/app/src/main/java/sh/lajo/buddy/BootReceiver.kt new file mode 100644 index 0000000..6f0867c --- /dev/null +++ b/app/src/main/java/sh/lajo/buddy/BootReceiver.kt @@ -0,0 +1,23 @@ +package sh.lajo.buddy + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.os.Build + +class BootReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.action == Intent.ACTION_BOOT_COMPLETED) { + val prefs = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE) + if (!prefs.getBoolean("onboardingFinished", false)) return + + val serviceIntent = Intent(context, WebSocketService::class.java) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + context.startForegroundService(serviceIntent) + } else { + context.startService(serviceIntent) + } + } + } +} -- cgit v1.2.3