當前位置: 首頁>>代碼示例>>Java>>正文


Java BluetoothServerSocket.close方法代碼示例

本文整理匯總了Java中android.bluetooth.BluetoothServerSocket.close方法的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothServerSocket.close方法的具體用法?Java BluetoothServerSocket.close怎麽用?Java BluetoothServerSocket.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.bluetooth.BluetoothServerSocket的用法示例。


在下文中一共展示了BluetoothServerSocket.close方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import android.bluetooth.BluetoothServerSocket; //導入方法依賴的package包/類
@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);
	}
}
 
開發者ID:tommai78101,項目名稱:android-5-way-Bluetooth-Relay,代碼行數:23,代碼來源:Runnables.java

示例2: doInBackground

import android.bluetooth.BluetoothServerSocket; //導入方法依賴的package包/類
@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;
}
 
開發者ID:andyzg,項目名稱:AndroidPad,代碼行數:20,代碼來源:ServerTask.java

示例3: tryToClose

import android.bluetooth.BluetoothServerSocket; //導入方法依賴的package包/類
private void tryToClose(@Nullable BluetoothServerSocket ss) {
	try {
		if (ss != null) ss.close();
	} catch (IOException e) {
		if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
	} finally {
		callback.transportDisabled();
	}
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:10,代碼來源:DroidtoothPlugin.java

示例4: tryToClose

import android.bluetooth.BluetoothServerSocket; //導入方法依賴的package包/類
private void tryToClose(BluetoothServerSocket ss) {
	try {
		if(ss != null) ss.close();
	} catch(IOException e) {
		if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
	}
}
 
開發者ID:kiggundu,項目名稱:briar,代碼行數:8,代碼來源:DroidtoothPlugin.java


注:本文中的android.bluetooth.BluetoothServerSocket.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。