本文整理匯總了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);
}
}
示例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;
}
示例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();
}
}
示例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);
}
}