public ConnectThread(BluetoothDevice device, BluetoothService service) { this.device = device; this.service = service; BluetoothSocket tmp = null; try { tmp = device.CreateRfcommSocketToServiceRecord(uUID); } catch (Exception e) { Toast.MakeText(Application.Context, "Create Failed due to " + e.Message, ToastLength.Long).Show(); } socket = tmp; service.state = ConnectionState.Connecting; }
public AcceptThread(BluetoothService service) { BluetoothServerSocket tmp = null; this.service = service; try { tmp = service.btAdapter.ListenUsingRfcommWithServiceRecord(App_Name, uUID); } catch (Exception e) { Toast.MakeText(Application.Context, "Listening Failed due to " + e.Message, ToastLength.Long).Show(); } serverSocket = tmp; service.state = ConnectionState.Listen; }
public ConnectedThread(BluetoothSocket socket, BluetoothService service) { this.socket = socket; this.service = service; Stream tmpIn = null; Stream tmpOut = null; try { tmpIn = socket.InputStream; tmpOut = socket.OutputStream; } catch (Exception e) { Toast.MakeText(Application.Context, "temp sockets not created due to " + e.Message, ToastLength.Long).Show(); } inStream = tmpIn; outStream = tmpOut; service.state = ConnectionState.Connected; }