Code example for BluetoothServerSocket

Methods: accept

0
 
    @Override 
    protected BluetoothSocket doInBackground(Void... params) {
        BluetoothSocket socket = null;
        try { 
            socket = mmServerSocket.accept();
            Log.i(TAG, "Connection accepted");
        } catch (IOException e) {
            Log.e(TAG, "Unable to accept connection", e);
        } 
        return socket;
    } 
 
    @Override 
    protected void onPostExecute(BluetoothSocket result) {
        if (result != null) {
            onAccepted(result);
        } 
    } 
 
    protected abstract void onAccepted(BluetoothSocket socket);