public SlaveExercise() { super(); final Handler mHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { if (msg.what == Constants.MESSAGE_SEND) { String message = (String) msg.obj; getMessage(message); } super.handleMessage(msg); } }; CommunicationManager communicationManager = CommunicationManager.getInstance(); BluetoothSocket socket = communicationManager.getSockets().get(0); CommunicationThread thread = new CommunicationThread(socket, mHandler); thread.start(); communicationThread = thread; }