Amirali Amirale
Amirali Amirale

Reputation: 111

android sleep mode, sockets reset exception

I am making chat app over android, everything is working well except when the device goes to sleep (lets say 30-45 minutes), then when I send any instance message through another device I can't get it or get the notification on the first device while notifications and instant messages got while not devices on sleep mode.

The problem I get is with the socket, the exception is connection reset, I know this happens if one of the sockets either on the server side or client side is closed, but on the server side is not closed.

On both devices wifi sleep is disabled so even on sleep mode wifi is working on both devices.

Also,I implemented a Service and that services runs a thread that thread handles socket communications.

Upvotes: 2

Views: 1413

Answers (1)

LuxuryMode
LuxuryMode

Reputation: 33741

The problem might be that the app itself has been killed or put into some other lifecycle state that prevents it from receiving messages. I think you'll need to implement a background service that listens for messages. This will decouple listening for messages from any particular activities, etc. Then when a message is received, you can simply display a notification which, when clicked, opens the app to display the message similar to how Google Talk works...

Upvotes: 1

Related Questions