/**
* Creates the thread
* @param playerToConnect player to connect to
*/
public ConnectionThread(Player playerToConnect) {
//gets the device to connect to (the player's device)
BluetoothDevice deviceToConnect = BluetoothServices.getmBluetoothAdapter().getRemoteDevice(playerToConnect.getMAC());
System.out.println("device to connect to");
System.out.println(deviceToConnect.getAddress());
System.out.println(deviceToConnect.getName());
System.out.println(deviceToConnect.toString());
System.out.println("device to connect to");
// Use a temporary object that is later assigned to mmSocket,
// because mmSocket is final
BluetoothSocket tmp = null;
// Get a BluetoothSocket to connect with the given BluetoothDevice (that is a player)
try {
// MY_UUID is the app's UUID string, also used by the reception part of the code
// creates and insecure RF socket
tmp = deviceToConnect.createInsecureRfcommSocketToServiceRecord(MainActivity.uuid);
System.out.println("Socket found!");
} catch (IOException e) { }
mmSocket = tmp;
}
ConnectionThread.java 文件源码
java
阅读 37
收藏 0
点赞 0
评论 0
项目:pass_the_bomb
作者:
评论列表
文章目录