当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothServerSocket.accept方法代码示例

本文整理汇总了Java中android.bluetooth.BluetoothServerSocket.accept方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothServerSocket.accept方法的具体用法?Java BluetoothServerSocket.accept怎么用?Java BluetoothServerSocket.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.bluetooth.BluetoothServerSocket的用法示例。


在下文中一共展示了BluetoothServerSocket.accept方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的android.bluetooth.BluetoothServerSocket.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。