I am done with connecting the Bluetooth to a paired device. After establishing the connection I want to move to the next activity, where the data to be sent are given by the user. so the main thing is, how can I send a string to an already connected Bluetooth device(from previous activity). Need help. I searched a lot. Couldn't find it. Thanks in advance
BluetoothConnectingActivity
private Runnable serverListener = new Runnable() { public void run() { try //opening of BT connection { //problematic with older phones... HELP: Change server/client orientation... //but solves: BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback
            Log.i("TrackingFlow", "Server socket: new way used...");
            socket = (BluetoothSocket) remoteDevice.getClass().getMethod("createRfcommSocket", new Class[]{int.class}).invoke(remoteDevice, 1);
            socket.connect();
            CONNECTION_ENSTABLISHED = true; //protect from failing
        } catch (Exception e) //obsolete way how to open BT
        {
            try {
                Log.e("TrackingFlow", "Server socket: old way used...");
                BluetoothServerSocket tmpsocket = adapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID);
                socket = tmpsocket.accept();
                CONNECTION_ENSTABLISHED = true; //protect from failing
                Log.i("TrackingFlow", "Listening...");
            } catch (Exception ie) {
                Log.e(TAG, "Socket's accept method failed", ie);
                ie.printStackTrace();
            }
        }
        Log.i(TAG, "Server is ready for listening...");
        runOnUiThread(new Runnable() {
            @Override
            public void run() { //Show message on UIThread
                listItems.clear(); //remove chat history
                listItems.add(0, String.format("  Server opened! Waiting for clients..."));
                listAdapter.notifyDataSetChanged();
            }
        });
        try //reading part
        {
            is = socket.getInputStream();
            os = socket.getOutputStream();
            new Thread(writter).start();
            int bufferSize = 1024;
            int bytesRead = -1;
            byte[] buffer = new byte[bufferSize];
            while (CONTINUE_READ_WRITE) //Keep reading the messages while connection is open...
            {
                final StringBuilder sb = new StringBuilder();
                bytesRead = is.read(buffer);
                if (bytesRead != -1) {
                    String result = "";
                    while ((bytesRead == bufferSize) && (buffer[bufferSize - 1] != 0)) {
                        result = result + new String(buffer, 0, bytesRead - 1);
                        bytesRead = is.read(buffer);
                    }
                    result = result + new String(buffer, 0, bytesRead - 1);
                    sb.append(result);
                }
                Log.e("TrackingFlow", "Read: " + sb.toString());
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() { //Show message on UIThread
                        Toast.makeText(ConnectToBluetoothActivity.this, sb.toString(), Toast.LENGTH_SHORT).show();
                        listItems.add(0, String.format("< %s", sb.toString())); //showing in history
                        listAdapter.notifyDataSetChanged();
                    }
                });
            }
        } catch (IOException e) {
            Log.e(TAG, "Server not connected...");
            e.printStackTrace();
        }
    }
};
StringSendingActivity
public void sendString(String convertedString) { //send converted string
    byte[] b = convertedString.getBytes();
    try {
        Toast.makeText(this, "Sending" + convertedString, Toast.LENGTH_SHORT).show();
        os.write(b);
        // list.add(0, "> " + et.getText().toString()); //chat history
        list.add(0, et.getText().toString()); //chat history
        final ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.message_textview, R.id.textview, list);
        listview.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        et.setText(""); //remove text after sending
    } catch (IOException e) {
        Toast.makeText(getApplicationContext(), "Not sent", Toast.LENGTH_SHORT).show(); //usually problem server-client decision
    }
}
