79490602

Date: 2025-03-06 20:28:12
Score: 1
Natty:
Report link

You have to use foreground services to allow running the websocket as service even with the screen turned-off

So you will instantiate inside this service a websocket client class from some library, that will allow you to treat the websocket connection (onOpen, OnClosed) In the onFailure event in the websocket client, you can schedule a reconnection that will be triggered from the websocket service to restart a new websocket client object.

I am using Kotlin.

https://developer.android.com/develop/background-work/services/fgs

Reasons:
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Manuel Pardo