List of usage examples for android.bluetooth BluetoothServerSocket accept
public BluetoothSocket accept(int timeout) throws IOException
From source file:com.duy.pascal.interperter.libraries.android.connection.bluetooth.AndroidBluetoothLib.java
@SuppressWarnings("unused") @PascalMethod(description = "Listens for and accepts a Bluetooth connection. Blocks until the connection is established or fails.") public String bluetoothAccept(@PascalParameter(name = "uuid") @RpcDefault(DEFAULT_UUID) String uuid, @PascalParameter(name = "timeout", description = "How long to wait for a new connection, 0 is wait for ever") @RpcDefault("0") Integer timeout) throws IOException { BluetoothServerSocket mServerSocket; mServerSocket = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(SDP_NAME, UUID.fromString(uuid)); BluetoothSocket mSocket = mServerSocket.accept(timeout); BluetoothConnection conn = new BluetoothConnection(mSocket, mServerSocket); return addConnection(conn); }
From source file:com.googlecode.android_scripting.facade.BluetoothFacade.java
@Rpc(description = "Listens for and accepts a Bluetooth connection. Blocks until the connection is established or fails.") public String bluetoothAccept(@RpcParameter(name = "uuid") @RpcDefault(DEFAULT_UUID) String uuid, @RpcParameter(name = "timeout", description = "How long to wait for a new connection, 0 is wait for ever") @RpcDefault("0") Integer timeout) throws IOException { BluetoothServerSocket mServerSocket; mServerSocket = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(SDP_NAME, UUID.fromString(uuid)); BluetoothSocket mSocket = mServerSocket.accept(timeout.intValue()); BluetoothConnection conn = new BluetoothConnection(mSocket, mServerSocket); return addConnection(conn); }