title: Android Java Socket Io Emitter can't send message
body: <p>For a few days I've been trying to get the socket.io chat example to work from <a href="https://socket.io/blog/native-socket-io-and-android/" rel="nofollow noreferrer">here</a>. First I tried it by typing everything myself. But it didn't work. Every time i get this error.</p>
  <p><strong>Attempt to invoke virtual method 'io.socket.emitter.Emitter io.socket.client.Socket.emit(java.lang.String, java.lang.Object[])' on a null object reference</strong></p>
  <p>I am getting messages from server, but when i am trying to send i am always getting that error. If i am just trying send String getting same error</p>
  <p>Here i am connecting</p>
  <pre><code>IO.Options options = new IO.Options();
      SocketSSL.set(options);
      Socket mSocket = null;
      try {
          mSocket = IO.socket(&quot;https://gaidena.lt:3000&quot;, options);
      } catch (URISyntaxException e) {
          e.printStackTrace();
      }
      mSocket.connect();
      mSocket.on(&quot;get&quot;, onNewMessage);
  </code></pre>
  <p>and here trying to send message</p>
  <pre><code>private void attemptSend() {
      String message = editTextMessage.toString().trim();
      if (TextUtils.isEmpty(message)) {
          return;
      }
  
      mSocket.emit(&quot;send&quot;, message);
  }
  </code></pre>
  <p>here getting messages</p>
  <pre><code>private Emitter.Listener onNewMessage = new Emitter.Listener() {
      @Override
      public void call(final Object... args) {
          getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  Log.d(TAG, args[0] + &quot;&quot;);
              }
          });
      }
  };
  </code></pre>