Socket.io-client-java: Battery drain issue

Created on 10 Jul 2017  路  3Comments  路  Source: socketio/socket.io-client-java

i am using socketio for android and working properly. now getting issue is that battery drain quickly when app used. how can i resolved that issue.

Most helpful comment

Actually, you should not do that.

If this is a chat app, use Firebase Cloud Messaging to intercept messages when the app is on the background and open the appropriate activity/fragment with the chat UI.

If the app is open the the socket should only connect in the activity/fragment that has the chat interface or depending on your implementation, you can register the socket on the application instance.

All 3 comments

@arpitjoshi08 Did you left the socket open all the time or you disconnect it after a process finish?

according to my need i have to connect socket every time even after app is kill from background (using in chat app)

Actually, you should not do that.

If this is a chat app, use Firebase Cloud Messaging to intercept messages when the app is on the background and open the appropriate activity/fragment with the chat UI.

If the app is open the the socket should only connect in the activity/fragment that has the chat interface or depending on your implementation, you can register the socket on the application instance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

commjoen picture commjoen  路  5Comments

RishabhDuttSharma picture RishabhDuttSharma  路  5Comments

arora-arpit picture arora-arpit  路  3Comments

pareshdevatval picture pareshdevatval  路  4Comments

noosxe picture noosxe  路  5Comments