Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Broadcasts(private val context: Application) {
})

clashRunning = StatusClient(context).currentProfile() != null
registered = true
} catch (e: Exception) {
Log.w("Register global receiver: $e", e)
}
Expand All @@ -113,6 +114,7 @@ class Broadcasts(private val context: Application) {
context.unregisterReceiver(broadcastReceiver)

clashRunning = false
registered = false
} catch (e: Exception) {
Log.w("Unregister global receiver: $e", e)
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/github/kr328/clash/remote/Remote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ object Remote {
fun launch() {
ApplicationObserver.attach(Global.application)

broadcasts.register()

ApplicationObserver.onVisibleChanged {
if(it) {
Log.d("App becomes visible")
service.bind()
broadcasts.register()
}
else {
Log.d("App becomes invisible")
service.unbind()
broadcasts.unregister()
}
}

Expand Down