Code example for BluetoothAdapter

Methods: listenUsingInsecureRfcommWithServiceRecord

0
    private class AcceptThread extends Thread {
    	private BluetoothServerSocket serverSocket;
    	 
    	public AcceptThread() { 
    		try { 
    			serverSocket = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord(SERVICE_NAME, SERVICE_ID);
    		} catch (IOException e) { }
    	} 
    	 
    	public void run() { 
    		BluetoothSocket socket = null;
    		Log.d(TAG, "--THREAD--");
    		while (true) { 
    			try { 
    				Log.d(TAG, "waiting...");
    				socket = serverSocket.accept();
    			} catch (IOException e) {
    				Log.e(TAG, "Fail to accept.", e);
    				break; 
    			} 
    			Log.d(TAG, "A connection was accepted.");