Example usage for android.bluetooth BluetoothServerSocket accept

List of usage examples for android.bluetooth BluetoothServerSocket accept

Introduction

In this page you can find the example usage for android.bluetooth BluetoothServerSocket accept.

Prototype

public BluetoothSocket accept(int timeout) throws IOException 

Source Link

Document

Block until a connection is established, with timeout.

Usage

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);
}