Reputation: 51
I'm working with Socket, using Socket.io Android Library & it's implemented well and working successfully. It's done, But it's in only single activity.
Now I want socket implementation in the entire application. Something more reliable and easy. I need socket listeners and methods to emit and receive in a single place so don't have to write everywhere.
I want a class where I can put all socket code and access it from anywhere and listen to that class all the time & pass an event to other Activities or Fragment if I receive anything in a socket.
What should be a good solution for this?
Thanks
Upvotes: 0
Views: 75
Reputation: 91
You should try moving your SocketIO implementation to a Service, it looks like the right use case to do it.
here you can find a post on how to implement it and do the communication activity/service Ways to communicate between activity and service
Upvotes: 2