public AcceptThread(BluetoothSerialService service)
            {
                _service = service;
                BluetoothServerSocket tmp = null;

                // Create a new listening server socket
                try {
                    tmp = _service._adapter.ListenUsingRfcommWithServiceRecord(NAME, MY_UUID);
                } catch (Java.IO.IOException e) {
                    Log.Error(TAG, "listen() failed", e);
                }
                mmServerSocket = tmp;
            }
            public ConnectThread(BluetoothDevice device, BluetoothSerialService service)
            {
                mmDevice = device;
                _service = service;
                BluetoothSocket tmp = null;

                // Get a BluetoothSocket for a connection with the
                // given BluetoothDevice
                try {
                    tmp = device.CreateRfcommSocketToServiceRecord(MY_UUID);
                } catch (Java.IO.IOException e) {
                    Log.Error(TAG, "create() failed", e);
                }
                mmSocket = tmp;
            }
            public ConnectedThread(BluetoothSocket socket, BluetoothSerialService service)
            {
                Log.Debug(TAG, "create ConnectedThread: ");
                mmSocket = socket;
                _service = service;
                Stream tmpIn  = null;
                Stream tmpOut = null;

                // Get the BluetoothSocket input and output streams
                try {
                    tmpIn  = socket.InputStream;
                    tmpOut = socket.OutputStream;
                } catch (Java.IO.IOException e) {
                    Log.Error(TAG, "temp sockets not created", e);
                }

                mmInStream  = tmpIn;
                mmOutStream = tmpOut;
            }
		private void SetupChat ()
		{
			Log.Debug (TAG, "SetupChat()");
	
			// Initialize the array adapter for the conversation thread
			conversationArrayAdapter = new ArrayAdapter<string> (this, Resource.Layout.message);
			conversationView = FindViewById<ListView> (Resource.Id.@in);
			conversationView.Adapter = conversationArrayAdapter;
			 
			// Initialize the compose field with a listener for the return key
			outEditText = FindViewById<EditText> (Resource.Id.edit_text_out);
			// The action listener for the EditText widget, to listen for the return key
			outEditText.EditorAction += delegate(object sender, TextView.EditorActionEventArgs e) {
				// If the action is a key-up event on the return key, send the message
				if (e.ActionId == ImeAction.ImeNull && e.Event.Action == KeyEventActions.Up) {
					var message = new Java.Lang.String (((TextView) sender).Text);
					SendMessage (message);
				}	
			};
			androidctx = this;
			// Initialize the send button with a listener that for click events
			sendButton = FindViewById<Button> (Resource.Id.button_send);
			sendButton.Click += delegate(object sender, EventArgs e) {
				// Send a message using content of the edit text widget
				var view = FindViewById<TextView> (Resource.Id.edit_text_out);
				var message = new Java.Lang.String (view.Text);
				SendMessage (message);
			};
			// Initialize the wifi button with a listener that for click events
			// Initialize the send button with a listener that for click events

			// Initialize the BluetoothChatService to perform bluetooth connections
			serialService = new BluetoothSerialService (this, new MyHandler (this));
			
			// Initialize the buffer for outgoing messages
			outStringBuffer = new StringBuffer ("");

			layout = new LinearLayout (this);



		}