Commit aec8377a authored by Lisa (AI Assistant)'s avatar Lisa (AI Assistant)

Fix: Call startForeground FIRST in onCreate

parent 029cfdc1
...@@ -52,10 +52,13 @@ class NodeService : Service() { ...@@ -52,10 +52,13 @@ class NodeService : Service() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
// CRITICAL: Call startForeground FIRST to avoid being killed
createNotificationChannel()
startForeground(NOTIFICATION_ID, createNotification())
// Initialize NodeClient with context for device identity persistence // Initialize NodeClient with context for device identity persistence
nodeClient.setContext(this) nodeClient.setContext(this)
// NodeClient is initialized directly above
// Debug: Write to file // Debug: Write to file
try { try {
val debugFile = java.io.File(cacheDir, "nodeservice_debug.txt") val debugFile = java.io.File(cacheDir, "nodeservice_debug.txt")
...@@ -63,7 +66,6 @@ class NodeService : Service() { ...@@ -63,7 +66,6 @@ class NodeService : Service() {
} catch (e: Exception) {} } catch (e: Exception) {}
Log.e(TAG, "NodeService onCreate called!") Log.e(TAG, "NodeService onCreate called!")
createNotificationChannel()
acquireWakeLock() acquireWakeLock()
// Auto-start with saved settings OR hardcoded defaults // Auto-start with saved settings OR hardcoded defaults
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment