public void run() {
        Log.i(TAG, "BEGIN mConnectedThread");
        
        if (listener != null) listener.newDeviceConnected(this);
        
        if (D) Log.i(TAG, "Starting the TimeoutThread for "+mTimeoutThread.getTime()+" milliseconds");
        mTimeoutThread.start();
        
        byte[] buffer = new byte[1024];
        int bytes;

        // Keep listening to the InputStream while connected
        while (true) {
            try {
                // Read from the InputStream
                bytes = mInStream.read(buffer);
                
                resetTimeout();

				if (bytes > 0) {
                    // Send the obtained bytes by the listener
                    if (listener != null) listener.incomingData(mSocket.getRemoteDevice(), bytes, buffer);
				}
                
            } catch (IOException e) {
                Log.e(TAG, "disconnected "+mDevice, e);
                if (listener != null) listener.connectionLost(mDevice);
                break;
            }
        }
    }