Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
openclaw-android-node
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lisa
openclaw-android-node
Commits
eeee42e0
Commit
eeee42e0
authored
Mar 11, 2026
by
Lisa (AI Assistant)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Delay startup to prevent ForegroundService crash
parent
41abc2b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
NodeService.kt
...main/java/com/nexlab/openclaw/node/service/NodeService.kt
+10
-4
No files found.
app/src/main/java/com/nexlab/openclaw/node/service/NodeService.kt
View file @
eeee42e0
...
@@ -120,7 +120,9 @@ class NodeService : Service() {
...
@@ -120,7 +120,9 @@ class NodeService : Service() {
try
{
try
{
when
(
intent
?.
action
)
{
when
(
intent
?.
action
)
{
"START"
->
{
"START"
->
{
// Call startForeground immediately first
startForeground
(
NOTIFICATION_ID
,
createNotification
())
startForeground
(
NOTIFICATION_ID
,
createNotification
())
// Get settings from Intent extras
// Get settings from Intent extras
var
protocol
=
intent
.
getStringExtra
(
"gateway_protocol"
)
?:
"WS"
var
protocol
=
intent
.
getStringExtra
(
"gateway_protocol"
)
?:
"WS"
var
ip
=
intent
.
getStringExtra
(
"gateway_ip"
)
?:
""
var
ip
=
intent
.
getStringExtra
(
"gateway_ip"
)
?:
""
...
@@ -140,11 +142,14 @@ class NodeService : Service() {
...
@@ -140,11 +142,14 @@ class NodeService : Service() {
// END TEMPORARY CONFIG
// END TEMPORARY CONFIG
val
fullUrl
=
if
(
protocol
==
"WSS"
)
"wss://$ip:$port"
else
"ws://$ip:$port"
val
fullUrl
=
if
(
protocol
==
"WSS"
)
"wss://$ip:$port"
else
"ws://$ip:$port"
System
.
out
.
println
(
"=== NodeService STARTED with URL: $fullUrl ==="
)
Log
.
d
(
TAG
,
"Starting with URL: $fullUrl, token present: ${token.isNotBlank()}"
)
// Debug: Write to file
// Delay startup briefly to let startForeground settle
try
{
android
.
os
.
Handler
(
android
.
os
.
Looper
.
getMainLooper
()).
postDelayed
({
System
.
out
.
println
(
"=== NodeService STARTED with URL: $fullUrl ==="
)
Log
.
d
(
TAG
,
"Starting with URL: $fullUrl, token present: ${token.isNotBlank()}"
)
// Debug: Write to file
try
{
val
debugFile
=
java
.
io
.
File
(
cacheDir
,
"nodeservice_debug.txt"
)
val
debugFile
=
java
.
io
.
File
(
cacheDir
,
"nodeservice_debug.txt"
)
debugFile
.
appendText
(
"START action: url=$fullUrl tokenLen=${token.length} nodeId=$nodeId\n"
)
debugFile
.
appendText
(
"START action: url=$fullUrl tokenLen=${token.length} nodeId=$nodeId\n"
)
}
catch
(
e
:
Exception
)
{}
}
catch
(
e
:
Exception
)
{}
...
@@ -155,6 +160,7 @@ class NodeService : Service() {
...
@@ -155,6 +160,7 @@ class NodeService : Service() {
}
catch
(
e
:
Exception
)
{}
}
catch
(
e
:
Exception
)
{}
scope
.
launch
{
startNode
(
fullUrl
,
token
,
nodeId
)
}
scope
.
launch
{
startNode
(
fullUrl
,
token
,
nodeId
)
}
},
500
)
// 500ms delay to let startForeground settle
}
}
"STOP"
->
{
"STOP"
->
{
scope
.
launch
{
stopNode
()
}
scope
.
launch
{
stopNode
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment