Android BluetoothServerSocket - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android BluetoothServerSocket class.

This code example shows how to use the following methods:close
        } 
 
        public void cancel() { 
        	RhoBluetoothManager.logi(TAG, "CANCEL mAcceptThread");
            try { 
                mmServerSocket.close();
            } catch (IOException e) {
                Log.e(TAG, "close() of server failed", e);
            } 
        } 
    } 
 
 
    /** 
     * This thread runs while attempting to make an outgoing connection 
     * with a device. It runs straight through; the connection either 
     * succeeds or fails. 
     */ 
    private class ConnectThread extends Thread {
        private final BluetoothSocket mmSocket;
7
CodeRank
This code example shows how to use the following methods:close
		mContext.sendStickyBroadcast(intent);
	} 
 
	public void cancel() { 
		try { 
			mServer.close();
		} catch (IOException e) {
		} 
	} 
 
	private void copyToFile(BluetoothSocket socket) throws IOException {
		InputStream input = socket.getInputStream();
		byte buf[] = new byte[8];
		fillBufferFromInputStream(buf, input);
		mBaseFilename = new String(buf);
		String filename = mBaseFilename + IMAGE_SUFFIX;
		OutputStream output = mContext.openFileOutput(filename,
				Context.MODE_WORLD_READABLE);
		byte[] b = new byte[1024];
		try { 
6
CodeRank
This code example shows how to use the following methods:close
        } 
 
        public void cancel() { 
            if (D) Log.d(TAG, "Socket Type" + mSocketType + "cancel " + this);
            try { 
                mmServerSocket.close();
            } catch (IOException e) {
                Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
            } 
        } 
    } 
 
 
    /** 
     * This thread runs while attempting to make an outgoing connection 
     * with a device. It runs straight through; the connection either 
     * succeeds or fails. 
     */ 
    private class ConnectThread extends Thread {
        private final BluetoothSocket mmSocket;
6
CodeRank
This code example shows how to use the following methods:accept, close
					BT_SERVICE_NAME, BT_SERVICE_UUID);
		} 
 
		@Override 
		protected void runIO() throws IOException { 
			socket = serverSocket.accept();
			serverSocket.close();
 
			manageConnection(socket.getInputStream(),
					socket.getOutputStream());
		} 
 
		@Override 
		public void cancel() { 
			try { 
				serverSocket.close();
			} catch (IOException e) {}
 
			try { 
				if (socket != null)
5
CodeRank
This code example shows how to use the following methods:close
    } 
 
    private void closeBluetoothServerSocket() { 
    	log.debug(CLASS + getId() + ": mmBluetoothServerSocket closing...");
    	try { 
            mmBluetoothServerSocket.close();
            log.debug(CLASS + getId() + ": mmBluetoothServerSocket closing - SUCCEEDED");
        } catch (IOException e) {
        	log.debug(CLASS + getId() + ": mmBluetoothServerSocket closing - FAILED");
        } 
    } 
     
    /** Will cancel the listening socket, and cause the thread to finish */ 
    public void cancel() { 
        closeBluetoothServerSocket(); 
    } 
	 
} 
6
CodeRank
This code example shows how to use the following methods:close
        } 
 
        public void cancel() { 
            if (D) Log.d(TAG, "Socket Type" + mSocketType + "cancel " + this);
            try { 
                mmServerSocket.close();
            } catch (IOException e) {
                Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
            } 
        } 
    } 
 
 
    /** 
     * This thread runs while attempting to make an outgoing connection 
     * with a device. It runs straight through; the connection either 
     * succeeds or fails. 
     */ 
    private class ConnectThread extends Thread {
        private final BluetoothSocket mmSocket;
5
CodeRank
This code example shows how to use the following methods:accept, close
	 
	@Override 
	protected BluetoothSocketWrapper doListening() throws Exception { 
		BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
		BluetoothServerSocket serverSocket = adapter.listenUsingInsecureRfcommWithServiceRecord(name, uuid);
		BluetoothSocket socket = serverSocket.accept();
		serverSocket.close();
		return new BluetoothSocketWrapper(socket);
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:close
        } 
 
        public void cancel() { 
            if (D) Log.d(TAG, "Socket Type" + mSocketType + "cancel " + this);
            try { 
                mmServerSocket.close();
            } catch (IOException e) {
                Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
            } 
        } 
    } 
 
 
    /** 
     * This thread runs while attempting to make an outgoing connection 
     * with a device. It runs straight through; the connection either 
     * succeeds or fails. 
     */ 
    private class ConnectThread extends Thread {
        private final BluetoothSocket mmSocket;
6
CodeRank
This code example shows how to use the following methods:close
            } 
        } 
 
        public void cancel() { 
            try { 
                mmServerSocket.close();
            } catch (IOException e) {
            } 
        } 
 
        private void doConnection(BluetoothSocket socket) {
            try { 
                socket.getOutputStream().write(mmData);
                socket.getOutputStream().flush();
                socket.close();
            } catch (IOException e) {
                Log.e(TAG, "Error writing content", e);
            } 
        } 
 
5
CodeRank
This code example shows how to use the following methods:close
        } 
    } 
 
    public void stopServer() { 
        try { 
            serverSocket.close();
        } catch (IOException e) {
            Log.e(TAG, "", e);
        } 
 
        shouldContinue = false;
    } 
} 
5
CodeRank

Related Android BluetoothServerSocket Questions & Answers:

See Code Examples for Android BluetoothServerSocket Methods: