Java 类android.bluetooth.BluetoothServerSocket 实例源码

项目:BleDemo    文件:BluetoothSPPService.java   
public AcceptThread(boolean secure)
{
    //Tmp变量
    BluetoothServerSocket tmp = null;

    //初始化类型
    mSocketType = secure ? "Secure":"Insecure";

    // 创建一个服务的Listener
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:ELM327    文件:BluetoothIOGateway.java   
public AcceptThread(boolean secure)
{
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try
    {
        if (secure)
        {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        }
        else
        {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    }
    catch (IOException e)
    {
        MyLog.e(TAG, "Listen to " + mSocketType + " socket type failed. More: ", e);
    }

    mmServerSocket = tmp;
}
项目:VR-One    文件:BluetoothListener.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
    mState = STATE_LISTEN;
}
项目:bluetooth-chat-appliction    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
    mState = STATE_LISTEN;
}
项目:AndroidSDK2.0    文件:BTAdt.java   
/**
 * Sets new server socket.
 */
public void setNewServerSocket()
{
    BluetoothServerSocket tmp = null;
    try
    {
        if(mProtocolVer == 2)
            tmp = mAdapter.listenUsingRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
        else
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
        NLog.d( "[BTAdt] ListenThread new BT ServerSocket assigned" );
    }
    catch ( IOException e )
    {
        NLog.e( "[BTAdt] ListenThread new BT ServerSocket assign fail", e );
    }

    mmServerSocket = tmp;
}
项目:SmartRC    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:Nird2    文件:DroidtoothPlugin.java   
@Override
public KeyAgreementListener createKeyAgreementListener(byte[] commitment) {
    if (!isRunning()) return null;
    // There's no point listening if we can't discover our own address
    String address = AndroidUtils.getBluetoothAddress(appContext, adapter);
    if (address.isEmpty()) return null;
    // No truncation necessary because COMMIT_LENGTH = 16
    UUID uuid = UUID.nameUUIDFromBytes(commitment);
    if (LOG.isLoggable(INFO)) LOG.info("Key agreement UUID " + uuid);
    // Bind a server socket for receiving invitation connections
    BluetoothServerSocket ss;
    try {
        ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
                "RFCOMM", uuid);
    } catch (IOException e) {
        if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
        return null;
    }
    BdfList descriptor = new BdfList();
    descriptor.add(TRANSPORT_ID_BLUETOOTH);
    descriptor.add(StringUtils.macToBytes(address));
    return new BluetoothKeyAgreementListener(descriptor, ss);
}
项目:Nird2    文件:DroidtoothPlugin.java   
@Override
public KeyAgreementListener createKeyAgreementListener(byte[] commitment) {
    if (!isRunning()) return null;
    // There's no point listening if we can't discover our own address
    String address = AndroidUtils.getBluetoothAddress(appContext, adapter);
    if (address.isEmpty()) return null;
    // No truncation necessary because COMMIT_LENGTH = 16
    UUID uuid = UUID.nameUUIDFromBytes(commitment);
    if (LOG.isLoggable(INFO)) LOG.info("Key agreement UUID " + uuid);
    // Bind a server socket for receiving invitation connections
    BluetoothServerSocket ss;
    try {
        ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
                "RFCOMM", uuid);
    } catch (IOException e) {
        if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
        return null;
    }
    BdfList descriptor = new BdfList();
    descriptor.add(TRANSPORT_ID_BLUETOOTH);
    descriptor.add(StringUtils.macToBytes(address));
    return new BluetoothKeyAgreementListener(descriptor, ss);
}
项目:SecretTalk    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
    mState = STATE_LISTEN;
}
项目:grblcontroller    文件:SerialThreadService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException | NullPointerException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
    mState = STATE_LISTEN;
}
项目:LittleBitLouder    文件:ServerThread.java   
public ServerThread(BluetoothAdapter adapter, Handler handler, boolean secure) {
    this.handler = handler;
    BluetoothServerSocket tempSocket = null;
    try {
        if (secure)
            tempSocket = adapter.listenUsingRfcommWithServiceRecord(Constants.NAME, UUID.fromString(Constants.UUID_STRING));
        else
            tempSocket = adapter.listenUsingInsecureRfcommWithServiceRecord(Constants.NAME, UUID.fromString(Constants.UUID_STRING));


    } catch (IOException ioe) {
        Log.e(TAG, ioe.toString());
    }
    serverSocket = tempSocket;

}
项目:buildAPKsSamples    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure":"Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:libcommon    文件:BluetoothManager.java   
/**
 * コンストラクタ
 * @param secure セキュア接続を待機するならtrue
 */
public ListeningThread(final boolean secure) {
    super("ListeningThread:" + mName);

    // Create a new listening server socket
    BluetoothServerSocket tmp = null;
    try {
        if (secure) {
        // セキュアな接続を行うためのBluetoothServerSocketを生成
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(mName, mSecureProfileUUID);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(mName, mInSecureProfileUUID);
        }
    } catch (final IOException e) {
        Log.w(TAG, e);
    }
    mmServerSocket = tmp;
}
项目:pet    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure":"Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
    }
    mmServerSocket = tmp;
}
项目:BlueDroid    文件:BlueService.java   
public AcceptThread(boolean isAndroid, boolean secure) {
    BluetoothServerSocket tmp = null;

    try {
        if (secure) {
            if (isAndroid)
                tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
            else
                tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
        } else {
            if (isAndroid)
                tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
            else
                tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    mmServerSocket = tmp;
}
项目:AndroidSDK    文件:BTAdt.java   
public void setNewServerSocket()
{
    BluetoothServerSocket tmp = null;

    try
    {
        tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
        //tmp = mAdapter.listenUsingRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
        NLog.d( "[BTAdt] ListenThread new BT ServerSocket assigned" );
    }
    catch ( IOException e )
    {
        NLog.e( "[BTAdt] ListenThread new BT ServerSocket assign fail", e );
    }

    mmServerSocket = tmp;
}
项目:Run-With-You    文件:BluetoothControlerImpl.java   
AcceptThread(boolean secure, int timeout) {
    BluetoothServerSocket tmp = null;
    this.mSecure = secure;
    this.mTimeout = timeout;

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + getSocketType(secure) + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:TastySnake    文件:AcceptThread.java   
/**
 * Initialize the thread.
 *
 * @param adapter The bluetooth adapter
 */
public AcceptThread(BluetoothAdapter adapter,
                    OnSocketEstablishedListener onSocketEstablishedListener,
                    OnStateChangedListener stateListener,
                    OnErrorListener errorListener) {
    super(TAG);
    this.onSocketEstablishedListener = onSocketEstablishedListener;
    this.stateListener = stateListener;
    this.errorListener = errorListener;
    BluetoothServerSocket tmp = null;
    try {
        tmp = adapter.listenUsingRfcommWithServiceRecord(
                Config.BLUETOOTH_SERVICE_NAME,
                UUID.fromString(Config.BLUETOOTH_UUID_STR));
    } catch (IOException e) {
        Log.e(TAG, "Error:", e);
        errorListener.onError(OnErrorListener.ERR_SOCKET_CREATE, e);
    }
    serverSocket = tmp;
}
项目:react-native-bluetooth-io    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
  BluetoothServerSocket tmp = null;
  mSocketType = secure ? "Secure" : "Insecure";

  // Create a new listening server socket
  try {
    if (secure) {
      tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
      MY_UUID_SECURE);
    } else {
      tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
      NAME_INSECURE, MY_UUID_INSECURE);
    }
  } catch (IOException e) {
    Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
  }
  mmServerSocket = tmp;
}
项目:IOT-DB410c-Course-3    文件:BluetoothManager.java   
/**********************************************************************
 * Name:        AcceptThread
 * Description: Constructor for the class. Attempts to instantiate the
 *              ServerSocket based on the passed parameter
 *
 * @param       secure boolean indicating the type of connection to
 *              listen for
 **********************************************************************/
public AcceptThread(boolean secure) {
  BluetoothServerSocket tmp = null;
  mSocketType = secure ? "Secure" : "Insecure";

  // Create a new listening server socket
  try {
    if (secure)
      tmp = btAdapter.listenUsingRfcommWithServiceRecord(
          NAME_SECURE, UUID_SECURE);
    else
      tmp = btAdapter.listenUsingInsecureRfcommWithServiceRecord(
          NAME_INSECURE, UUID_INSECURE);
  } catch (IOException e) {
    e.printStackTrace();
  }
  mmServerSocket = tmp;
}
项目:gesture-framework    文件:AcceptThread.java   
public AcceptThread(BluetoothChannel channel, BluetoothAdapter bluetoothAdapter) {
    this.mChannel = channel;

    bluetoothAdapter.cancelDiscovery();

    BluetoothServerSocket tmp = null;

    try {
        tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord("SysplaceApp",
                BluetoothChannel.MY_UUID);
    } catch (IOException e) {
        Log.e(TAG, "Could not open Server Socket");
    }

    mmServerSocket = tmp;
}
项目:blink    文件:BluetoothSerialService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure":"Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:blink    文件:BluetoothSerialService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure":"Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:phonepick    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    //mSocketType = secure ? "Secure" : "Insecure";
    mSocketType = "Insecure";
    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:secureit    文件:BluetoothServerTask.java   
public BluetoothServerTask(Context context) throws NoBluetoothException {

    Log.i("BluetoothServerTask", "Created");
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBluetoothAdapter == null) {
        // Device does not support Bluetooth
        throw new NoBluetoothException();

    }
    this.context = context;
    Log.i("BluetoothServerTask", "Got adapter");
    // Use a temporary object that is later assigned to mmServerSocket,
    // because mmServerSocket is final
    BluetoothServerSocket tmp = null;
    try {
        // MY_UUID is the app's UUID string, also used by the client code
        tmp = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord(
                Remote.BLUETOOTH_NAME, 
                Remote.BLUETOOTH_UUID);
        Log.i("BluetoothServerTask", "Created insecure server socket");
    } catch (IOException e) { 
        throw new NoBluetoothException();
    }
    mmServerSocket = tmp;
}
项目:honki_android    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:DemoArduinoAndroidCordovaBT    文件:BluetoothSerialService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure":"Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:DemoArduinoAndroidCordovaBT    文件:BluetoothSerialService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure":"Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:pga309-blutooth-android-tensometer    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:tilt-game-android    文件:BluetoothServerService.java   
public AcceptThread(boolean secure) {
    _socketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    BluetoothServerSocket serverSocket = null;
    try {
        if (secure) {
            if (_debug) Log.d(TAG, "AcceptThread: started listening secure, uuid = " + _secureUuid + ", spd name = " + _secureSPDName);
            serverSocket = _adapter.listenUsingRfcommWithServiceRecord(_secureSPDName, _secureUuid);
        } else {
            if (_debug) Log.d(TAG, "AcceptThread: started listening insecure, uuid = " + _insecureUuid + ", spd name = " + _insecureSPDName);
            serverSocket = _adapter.listenUsingInsecureRfcommWithServiceRecord(_insecureSPDName, _insecureUuid);
        }
    } catch (IOException e) {
        Log.e(TAG, "AcceptThread: listen failed");
        e.printStackTrace();
    }

    _serverSocket = serverSocket;

    _isListening = true;
}
项目:binea_project_for_android    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, BASKET_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:ArduinoAndroidBluetoothSerialComm    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
            BluetoothServerSocket tmp = null;
            mSocketType = secure ? "Secure" : "Insecure";

            // Create a new listening server socket
            try {
//                if (secure) {
//                    tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
//                            MY_UUID_SECURE);
//                } else {
                    tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                            NAME_INSECURE, MY_UUID_INSECURE);
//                }
            } catch (IOException e) {
                Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
            }
            mmServerSocket = tmp;
        }
项目:AndroidSmoothBluetooth    文件:BluetoothService.java   
public AcceptThread(boolean isAndroid, boolean secure) {
    BluetoothServerSocket tmp = null;

    // Create a new listening server socket
    try {
        if (secure) {
            if(isAndroid)
                tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
            else
                tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
        } else {
            if(isAndroid)
                tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
            else
                tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
        }
    } catch (IOException e) { }
    mmServerSocket = tmp;
}
项目:HackChat    文件:BluetoothChatService.java   
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
项目:TheWonderfulRedtoothMachine    文件:ListernerBluetoothThread.java   
public ListernerBluetoothThread(final ProxyManager proxyManager) {

        final BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        BluetoothServerSocket tmp = null;
        try {
            // MY_UUID is the app's UUID string, also used by the client code
            tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, proxyManager
            .getUuidSecure());

        } catch (Exception ex) {
            Log.e(TAG, "Fail", ex);
        }
        mmServerSocket = tmp;

        this.proxyManager = proxyManager;

    }
项目:Bleu    文件:HostActivity.java   
public AcceptThread() {
    BluetoothServerSocket tmp = null;
    isAccepting = true;

    try {
        tmp = mBluetoothAdapter.
                listenUsingRfcommWithServiceRecord(
                        mChatRoomName, java.util.UUID.fromString(MainActivity.UUID)
                );
    } catch (IOException e) {
        System.err.println("Failed to set up Accept Thread");
        System.err.println(e.toString());
    }

    mmServerSocket = tmp;
}
项目:android-5-way-Bluetooth-Relay    文件:Runnables.java   
@Override
public void run() {
    try {
        Log.d("DEBUG", "Listening with uuid: " + Main.uuids[iterator].toString());
        BluetoothServerSocket serverSocket = adapter.listenUsingRfcommWithServiceRecord(Integer.toString(iterator), Main.uuids[iterator]);
        Log.d("DEBUG", "Accepting...");
        socket = serverSocket.accept();
        Log.d("DEBUG", "Connected. Closing server socket.");
        serverSocket.close();

        //TODO: (Accept) Pass the socket to another thread for read/write management.
        Manage thread = new Manage(socket);
        manageThreads.add(thread);
        executor.execute(thread);

        /*Log.d("DEBUG", "Not doing anything. Closing connected socket.");
        socket.close();*/
    }
    catch (IOException e) {
        Log.d("DEBUG", "Exception", e);
    }
}
项目:AndroidPad    文件:ServerTask.java   
@Override
protected BluetoothSocket doInBackground(BluetoothAdapter... bt) {
    BluetoothSocket mSocket = null;
    Log.d(TAG, "Starting doinbackground");
    try {
        Log.d(TAG, bt[0].getName());
        BluetoothServerSocket server = bt[0].listenUsingInsecureRfcommWithServiceRecord(name, uuid);
        Log.d(TAG, "Received serversocket from UUID " + uuid + ", now accepting");
        mSocket = server.accept();

        Log.d(TAG, "Received socket, closing server");
        server.close();
    } catch (IOException e) {
        e.printStackTrace();
        Log.d("AsyncTask", "Unable to get bluetooth socket");
    }

    return mSocket;
}
项目:SimpleBluetoothLibrary    文件:BluetoothUtility.java   
public AcceptThread() {
    // Use a temporary object that is later assigned to mmServerSocket,
    // because mmServerSocket is final
    BluetoothServerSocket tmp = null;
    try {
        // MY_UUID is the app's UUID string, also used by the client code
        tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord(SERVER_NAME, SERVER_UUID);
    } catch (IOException e) { }
    mmServerSocket = tmp;

    if(bluetoothHandler != null) {
        bluetoothHandler
                .obtainMessage(BluetoothHandler.MESSAGE_WAIT_FOR_CONNECTION)
                .sendToTarget();
    }
}
项目:blue-chat    文件:HostActivity.java   
public AcceptThread() {
    BluetoothServerSocket tmp = null;
    isAccepting = true;

    try {
        tmp = mBluetoothAdapter.
                listenUsingRfcommWithServiceRecord(
                        mChatRoomName, java.util.UUID.fromString(MainActivity.UUID)
                );
    } catch (IOException e) {
        System.err.println("Failed to set up Accept Thread");
        System.err.println(e.toString());
    }

    mmServerSocket = tmp;
}