Posts

Showing posts with the label android-background

Socket connection in background

Socket connection in background I need to make an application where, while the user is authorized, it keeps the socket connection until it is logged out. For this purpose, a foreground service is created, which starts after the authorization of the user, and stops when it is logged out. It implements connection and reconnection on the socket. All works well until you press the power button and turn off the charging. After this, the user stops receiving pongs from the server and the SocketTimeoutException is received on the OkHttp, and also stops receiving messages on the socket. On JavaWebsocket The connection was closed because the other endpoint did not respond with a pong in time. is received, after which you can successfully create a new socket connection, but it will repeat the same problem in the loop. In the settings, the optimization of the battery for this application was disabled. What can I do to make a stable connection socket work in the background? Implementation of acti...

Android periodic work friendly to doze mode and app standby

Android periodic work friendly to doze mode and app standby I'm trying to found a best way to perform periodic work in android that will play nicely with doze mode and app standby. I've tried WorkManager with periodic request, it works fine at the beginning (for 15 mins requests) but the time slots diminishes as time goes by, after a week its seems to get triggered only once per day. What is the best way to get the required behavior and still be doze mode and app standby friendly? If you have a server I think FCM this is your best option: developer.android.com/training/monitoring-device-state/… – Hed Shafran Jul 1 at 10:44 I thought about it(FCM), but after reading the FCM documentation, I've decided it's not the way, in docs it's stated ". High priority messages generally should result i...