Code example for BluetoothServerSocket

Methods: accept, close

0
			execute();
		} 
		protected Void doInBackground(Void... params) {
			try { 
				// the server wait to connected with time out of 20 sec 
				sSocket = serverSocket.accept(TIME_OUT);
				// iharel: serverSocket = null; 
				if (sSocket != null) {
					// cancel the scanning because is slowly the connection 
					serverSocket.close();
					btAdapter.cancelDiscovery();
				} 
			} catch (IOException e) {// if serverSocket.accept() threw an exception or cancelDiscovery, we want to call the serverClosed method
				publishProgress();  
				this.cancel(true);
			} 
			return null; 
		} 
		protected void onProgressUpdate(Void... values) {
			serverClosed.serverClosed();
		}