Implementation of Socket on Android Java Platform
Implementation of Socket on Android Let us go through the steps for implementation. I have ready fair amount of tutorials and videos. And finally able to get it running with little tweak. Here goes the code. Here we apply socket to MainActivity.java file. This is where we display different counts which changes based on the value emitted from socket. We write this code before start of onCreate event. private Socket mSocket ; TextView textview; // Here we display result obtained from server { try { mSocket = IO . socket ( "https://your_server_name.com" ); // http://chat.socket.io } catch ( URISyntaxException e) { e.printStackTrace(); } } Inside onCreate method: textview = findViewById( R . id . tv_ textview); // Then inside onCreate method, initialise socket mSocket .on( "new message" , onNewMessage ); mSocket .connect(); // Here "new message" is the function we will observe. onNewMessage is is an object of the class Emitter.L...