diff options
| author | JustZvan <justzvan@justzvan.xyz> | 2026-02-06 13:38:36 +0100 |
|---|---|---|
| committer | JustZvan <justzvan@justzvan.xyz> | 2026-02-06 13:38:36 +0100 |
| commit | adb6a4fd9ec3a23c04d5e4c2ce799448237915c4 (patch) | |
| tree | 786edcf5888788e0667a90fae96d7ebec68c507a /app/src/main/java/sh/lajo/buddy/BootReceiver.kt | |
feat: initial commit
Diffstat (limited to 'app/src/main/java/sh/lajo/buddy/BootReceiver.kt')
| -rw-r--r-- | app/src/main/java/sh/lajo/buddy/BootReceiver.kt | 23 |
1 files changed, 23 insertions, 0 deletions
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) + } + } + } +} |