本文整理汇总了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);
}
}