Exemple #1
0
            public AcceptThread(BluetoothChatService 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;
            }
Exemple #2
0
        private void SetupChat()
        {
            Android.Util.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 BluetoothChatService to perform bluetooth connections
            chatService = new BluetoothChatService(this, new MyHandler(this), _reader);

            // Initialize the buffer for outgoing messages
            outStringBuffer = new StringBuffer("");
        }
Exemple #3
0
            public ConnectThread(BluetoothDevice device, BluetoothChatService 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;
            }
Exemple #4
0
            public ConnectedThread(BluetoothSocket socket, BluetoothChatService 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;
            }