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.
@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.
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.